Skip to content

Commit 41d162b

Browse files
committed
Clear search input on index route
1 parent af26bb3 commit 41d162b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

app/routes/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default Route.extend({
1414
},
1515

1616
setupController(controller) {
17+
this.controllerFor('application').set('searchQuery', null);
1718
controller.dataTask.perform();
1819
},
1920
});

tests/acceptance/search-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ module('Acceptance | search', function(hooks) {
6060
assert.dom('[data-test-search-nav]').hasText('Displaying 1-8 of 8 total results');
6161
});
6262

63+
test('clearing search results', async function(assert) {
64+
this.server.loadFixtures();
65+
66+
await visit('/search?q=rust');
67+
68+
assert.equal(currentURL(), '/search?q=rust');
69+
assert.dom('[data-test-search-input]').hasValue('rust');
70+
71+
await visit('/');
72+
73+
assert.equal(currentURL(), '/');
74+
assert.dom('[data-test-search-input]').hasValue('');
75+
});
76+
6377
test('pressing S key to focus the search bar', async function(assert) {
6478
this.server.loadFixtures();
6579

0 commit comments

Comments
 (0)