Skip to content

Commit

Permalink
Fix #5855: Dropdown search filtering ignore meta keys (#5857)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Jan 30, 2024
1 parent ad59eb0 commit 5c6b96e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
39 changes: 19 additions & 20 deletions components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,23 @@ export const Dropdown = React.memo(
};

const onInputKeyDown = (event) => {
switch (event.which) {
//down
case 40:
switch (event.code) {
case 'ArrowDown':
onDownKey(event);
break;

//up
case 38:
case 'ArrowUp':
onUpKey(event);
break;

//space and enter
case 32:
case 13:
case 'Space':
case 'Enter':
overlayVisibleState ? hide() : show();
event.preventDefault();
break;

//escape and tab
case 27:
case 9:
case 'Escape':
case 'Tab':
hide();
break;

Expand All @@ -176,20 +172,17 @@ export const Dropdown = React.memo(
};

const onFilterInputKeyDown = (event) => {
switch (event.which) {
//down
case 40:
switch (event.code) {
case 'ArrowDown':
onDownKey(event);
break;

//up
case 38:
case 'ArrowUp':
onUpKey(event);
break;

//enter and escape
case 13:
case 27:
case 'Escape':
case 'Enter':
hide();
event.preventDefault();
break;
Expand Down Expand Up @@ -294,9 +287,15 @@ export const Dropdown = React.memo(
clearTimeout(searchTimeout.current);
}

if (event.ctrlKey || event.metaKey || event.altKey) {
// ignore meta combinations like CTRL+F for browser search
return;
}

const char = event.key;

if (char === 'Shift' || char === 'Control' || char === 'Alt') {
if (char.length !== 1) {
// only single character keys matter for searching
return;
}

Expand Down
2 changes: 2 additions & 0 deletions components/lib/dropdown/DropdownBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ export const DropdownBase = ComponentBase.extend({
inputId: null,
inputRef: null,
itemTemplate: null,
loading: false,
loadingIcon: null,
maxLength: null,
name: null,
onBlur: null,
Expand Down

0 comments on commit 5c6b96e

Please sign in to comment.