From 5f80c5d9f81f3c5398c3e6e3e84fd6c67c8873f1 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Mon, 23 Nov 2015 18:22:33 -0500 Subject: [PATCH] Resize search after removing a choice This fixes a previous bug with the backspace handler on the multiple select search box where unselecting a choice through the keyboard would not properly size the search box. As a result, most of the text would be cut off and it was very clear that there was an issue. In addition, a blank space was automatically being added to the end of the search query. This blank space would not be removed at all, so the user had to manually remove it. Additionally, a query would be triggered for the last used search term instead of the new search term that would be loaded in. This caused incorrect results to be displayed most of the time. All of these issues have been fixed by triggering a new search query after an option has been removed through the keyboard. This will resize the search box automatically, which fixes the main issue, and it will trigger a search with the correct query. This closes https://github.com/select2/select2/issues/3297 This closes https://github.com/select2/select2/pull/3398 --- src/js/select2/selection/search.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/js/select2/selection/search.js b/src/js/select2/selection/search.js index 92808a68..7dc12a75 100644 --- a/src/js/select2/selection/search.js +++ b/src/js/select2/selection/search.js @@ -193,9 +193,8 @@ define([ data: item }); - this.trigger('open', {}); - - this.$search.val(item.text + ' '); + this.$search.val(item.text); + this.handleSearch(); }; Search.prototype.resizeSearch = function () {