Skip to content

Commit

Permalink
fix(dropdown): use central delimiter char instead of key
Browse files Browse the repository at this point in the history
On a multiple dropdown, having allowAdditions:true, the press of the delimiter key (comma by default) was checked via the keycode. However the keycode does not take possible pressed shift/alt keys into account.
This results in triggering a multi dropdown entry even when pressing the key together with shift/alt, so it was not possible to declare for example the semicolon as a delimiter.

As we already have the delimiter string for concatenation/splitting of existing values, this PR now also uses that setting for the keypress.
  • Loading branch information
lubber-de committed Feb 27, 2022
1 parent aac4c50 commit 123b50f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/definitions/modules/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ $.fn.dropdown = function(parameters) {
keydown: function(event) {
var
pressedKey = event.which,
isShortcutKey = module.is.inObject(pressedKey, keys)
isShortcutKey = module.is.inObject(pressedKey, keys) || event.key === settings.delimiter
;
if(isShortcutKey) {
var
Expand All @@ -1549,7 +1549,7 @@ $.fn.dropdown = function(parameters) {
hasSubMenu = ($subMenu.length> 0),
hasSelectedItem = ($selectedItem.length > 0),
selectedIsSelectable = ($selectedItem.not(selector.unselectable).length > 0),
delimiterPressed = (pressedKey == keys.delimiter && module.is.multiple()),
delimiterPressed = (event.key === settings.delimiter && module.is.multiple()),
isAdditionWithoutMenu = (settings.allowAdditions && settings.hideAdditions && (pressedKey == keys.enter || delimiterPressed) && selectedIsSelectable),
$nextItem,
isSubMenuItem,
Expand Down Expand Up @@ -4131,7 +4131,6 @@ $.fn.dropdown.settings = {

keys : {
backspace : 8,
delimiter : 188, // comma
deleteKey : 46,
enter : 13,
escape : 27,
Expand Down

0 comments on commit 123b50f

Please sign in to comment.