From 3fe5c551d35e7bb8463102a62feafe0b89c0e414 Mon Sep 17 00:00:00 2001 From: Codeborne Date: Mon, 17 Oct 2016 10:36:10 +0300 Subject: [PATCH] #4506 do not change selection when previously selected element is unfiltered firstUnfiltered() forced change of selection even if previously selected element was visible. This meant that when tabbing through the field, the selected option was changed to first visible. --- src/definitions/modules/dropdown.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 0ae40b02b..3f6004512 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -263,6 +263,15 @@ $.fn.dropdown = function(parameters) { select: { firstUnfiltered: function() { + module.verbose('Ensuring that an unfiltered option is selected'); + var visibleExistingSelectedItem = $item.filter( + '.' + className.selected + + ':not(.' + className.filtered + ')' + + ':not(.' + className.disabled + ')'); + if (visibleExistingSelectedItem.length) { + module.verbose('Previously selected element is unfiltered, not changing selection'); + return; + } module.verbose('Selecting first non-filtered element'); module.remove.selectedItem(); $item