Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve scroll position for code-search #134

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/code-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions tests/acceptance/code-search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down