From 24c6803391a3aa37c251113e171ed376883e8195 Mon Sep 17 00:00:00 2001 From: Paul Laros Date: Thu, 12 Jan 2017 15:13:21 +0100 Subject: [PATCH 1/2] Added resetScrollPosition option --- README.md | 1 + assets/scripts/src/choices.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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) { From ce5b9d75159b9c6ed3d01c8dadc0b29acb8777ac Mon Sep 17 00:00:00 2001 From: Paul Laros Date: Sat, 14 Jan 2017 15:51:38 +0100 Subject: [PATCH 2/2] Updated README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 71f3d76..ddf8d5a 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,13 @@ Pass an array of objects: **Usage:** Whether the dropdown should appear above the input (rather than beneath) if there is not enough space within the window. +### resetScrollPosition +**Type:** `Boolean` **Default:** `true` + +**Input types affected:** `select-multiple` + +**Usage:** Whether the scroll position should reset after adding an item. + ### regexFilter **Type:** `Regex` **Default:** `null`