Browse Source

Fix issue with hideAdditions where enter key would not select value when typing rapidly

pull/4273/head
Jack Lukic 8 years ago
parent
commit
77980c1864
1 changed files with 4 additions and 1 deletions
  1. 5
      src/definitions/modules/dropdown.js

5
src/definitions/modules/dropdown.js

@ -1296,7 +1296,7 @@ $.fn.dropdown = function(parameters) {
hasSelectedItem = ($selectedItem.length > 0), hasSelectedItem = ($selectedItem.length > 0),
selectedIsSelectable = ($selectedItem.not(selector.unselectable).length > 0), selectedIsSelectable = ($selectedItem.not(selector.unselectable).length > 0),
delimiterPressed = (pressedKey == keys.delimiter && settings.allowAdditions && module.is.multiple()), 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, $nextItem,
isSubMenuItem, isSubMenuItem,
newIndex newIndex
@ -1304,6 +1304,7 @@ $.fn.dropdown = function(parameters) {
// allow selection with menu closed // allow selection with menu closed
if(isAdditionWithoutMenu) { if(isAdditionWithoutMenu) {
$selectedItem = $menu.children(selector.addition);
module.verbose('Selecting item from keyboard shortcut', $selectedItem); module.verbose('Selecting item from keyboard shortcut', $selectedItem);
module.event.item.click.call($selectedItem, event); module.event.item.click.call($selectedItem, event);
if(module.is.searchSelection()) { if(module.is.searchSelection()) {
@ -2570,6 +2571,7 @@ $.fn.dropdown = function(parameters) {
return; return;
} }
if(value === '' || alreadyHasValue) { if(value === '' || alreadyHasValue) {
console.log('removing addition');
$addition.remove(); $addition.remove();
return; return;
} }
@ -2594,6 +2596,7 @@ $.fn.dropdown = function(parameters) {
$addition $addition
.prependTo($menu) .prependTo($menu)
; ;
$item.add($addition);
module.verbose('Adding item choice to menu corresponding with user choice addition', $addition); module.verbose('Adding item choice to menu corresponding with user choice addition', $addition);
} }
if(!settings.hideAdditions || module.is.allFiltered()) { if(!settings.hideAdditions || module.is.allFiltered()) {

Loading…
Cancel
Save