diff --git a/README.md b/README.md index f471862..71f3d76 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Or include Choices directly: search: true, searchFloor: 1, flip: true, + resetScrollPosition: true, regexFilter: null, shouldSort: true, sortFilter: () => {...}, diff --git a/assets/scripts/src/choices.js b/assets/scripts/src/choices.js index b890c10..c04660b 100644 --- a/assets/scripts/src/choices.js +++ b/assets/scripts/src/choices.js @@ -60,6 +60,7 @@ class Choices { search: true, searchFloor: 1, flip: true, + resetScrollPosition: true, regexFilter: null, shouldSort: true, sortFilter: sortByAlpha, @@ -391,8 +392,11 @@ class Choices { // Clear choices this.choiceList.innerHTML = ''; + // Scroll back to top of choices list - this.choiceList.scrollTop = 0; + if(this.config.resetScrollPosition){ + this.choiceList.scrollTop = 0; + } // If we have grouped options if (activeGroups.length >= 1 && this.isSearching !== true) {