From f7ad2ce8bbb0684515591edf2dc44071c656bbf4 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Tue, 30 Oct 2018 10:50:50 -0700 Subject: [PATCH] Add a resetPagination method to the searchable mixin Searchable can be used without pagination, but reseting pagination is more a function of search than pagination insofar as if you add search to a page, you are also going to want automatic pagination resetting. --- ui/app/mixins/searchable.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui/app/mixins/searchable.js b/ui/app/mixins/searchable.js index 180e4e1b3..0dfa9ba3e 100644 --- a/ui/app/mixins/searchable.js +++ b/ui/app/mixins/searchable.js @@ -36,6 +36,16 @@ export default Mixin.create({ fuzzySearchEnabled: false, regexEnabled: true, + // Search should reset pagination. Not every instance of + // search will be paired with pagination, but it's still + // preferable to generalize this rather than risking it being + // forgotten on a single page. + resetPagination() { + if (this.get('currentPage') != null) { + this.set('currentPage', 1); + } + }, + fuse: computed('listToSearch.[]', 'fuzzySearchProps.[]', function() { return new Fuse(this.get('listToSearch'), { shouldSort: true,