diff --git a/app/controllers/code-search.js b/app/controllers/code-search.js index b034aa8f..97055044 100644 --- a/app/controllers/code-search.js +++ b/app/controllers/code-search.js @@ -2,6 +2,7 @@ import Controller from '@ember/controller'; export default Controller.extend({ queryParams: ['codeQuery', 'sort', 'sortAscending', 'regex', 'fileFilter'], + preserveScrollPosition: true, codeQuery: '', sort: 'name', sortAscending: true, diff --git a/tests/acceptance/code-search-test.js b/tests/acceptance/code-search-test.js index a418537f..13a35bfe 100644 --- a/tests/acceptance/code-search-test.js +++ b/tests/acceptance/code-search-test.js @@ -175,8 +175,11 @@ module('Acceptance | code search', function(hooks) { assert.dom(nameSortButton).hasClass('selected'); assert.ok(nameSortButton.querySelector('.icon-expand-less')); + window.scrollTo(0, 10); await click(usageSortButton); + assert.notEqual(window.pageYOffset, 0, 'Page remains scrolled (not at top)'); + let resortedAddonNames = findAll('.test-addon-name'); assert.dom(resortedAddonNames[0]).containsText('ember-foo', 'Addons are sorted descending by default for switch to usage count sort'); assert.dom(resortedAddonNames[1]).containsText('ember-blanket', 'Addons are sorted descending by usage count'); @@ -380,8 +383,11 @@ module('Acceptance | code search', function(hooks) { assert.dom('.test-addon-name').exists({ count: 3 }, 'shows all addons before filtering'); + window.scrollTo(0, 10); await fillIn('.test-file-filter-input', filterTerm); + assert.notEqual(window.pageYOffset, 0, 'Page remains scrolled (not at top)'); + assert.dom('.test-addon-name').exists({ count: 2 }, 'shows only matching addons after filtering'); assert.dom('.test-result-info').containsText('3 addons', 'full result count shows when filter is applied'); assert.dom('.test-result-info').containsText('6 usages', 'full usage count shows when filter is applied');