From 77980c1864abecd50ca2a64eba564c42c136f294 Mon Sep 17 00:00:00 2001 From: Jack Lukic Date: Sun, 26 Jun 2016 16:22:44 -0400 Subject: [PATCH] Fix issue with hideAdditions where enter key would not select value when typing rapidly --- src/definitions/modules/dropdown.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index bdc7ed88a..bf7c548db 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -1296,7 +1296,7 @@ $.fn.dropdown = function(parameters) { hasSelectedItem = ($selectedItem.length > 0), selectedIsSelectable = ($selectedItem.not(selector.unselectable).length > 0), delimiterPressed = (pressedKey == keys.delimiter && settings.allowAdditions && module.is.multiple()), - isAdditionWithoutMenu = (settings.allowAdditions && settings.hideAdditions && (pressedKey == keys.enter || delimiterPressed) && selectedIsSelectable), + isAdditionWithoutMenu = (settings.allowAdditions && settings.hideAdditions && (pressedKey == keys.enter || delimiterPressed)), $nextItem, isSubMenuItem, newIndex @@ -1304,6 +1304,7 @@ $.fn.dropdown = function(parameters) { // allow selection with menu closed if(isAdditionWithoutMenu) { + $selectedItem = $menu.children(selector.addition); module.verbose('Selecting item from keyboard shortcut', $selectedItem); module.event.item.click.call($selectedItem, event); if(module.is.searchSelection()) { @@ -2570,6 +2571,7 @@ $.fn.dropdown = function(parameters) { return; } if(value === '' || alreadyHasValue) { + console.log('removing addition'); $addition.remove(); return; } @@ -2594,6 +2596,7 @@ $.fn.dropdown = function(parameters) { $addition .prependTo($menu) ; + $item.add($addition); module.verbose('Adding item choice to menu corresponding with user choice addition', $addition); } if(!settings.hideAdditions || module.is.allFiltered()) {