Skip to content

Commit

Permalink
Fix tab focus
Browse files Browse the repository at this point in the history
* Fixes #1234
* Fixes #1209 (comment)
  • Loading branch information
zoglo committed Dec 20, 2024
1 parent a127f82 commit cd677b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/scripts/choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,17 @@ class Choices {
(event.key.length === 2 && event.key.charCodeAt(0) >= 0xd800) ||
event.key === 'Unidentified';

if (!this._isTextElement && !hasActiveDropdown) {
/*
We do not show the dropdown if the keycode was tab or esc
as these one are used to focusOut of e.g. select choices.
An activated search can still be opened with any other key.
*/
if (
!this._isTextElement &&
!hasActiveDropdown &&
keyCode !== KeyCodeMap.ESC_KEY &&
keyCode !== KeyCodeMap.TAB_KEY
) {
this.showDropdown();

if (!this.input.isFocussed && wasPrintableChar) {
Expand Down
1 change: 1 addition & 0 deletions src/scripts/interfaces/keycode-map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const KeyCodeMap = {
TAB_KEY: 9,
BACK_KEY: 46,
DELETE_KEY: 8,
ENTER_KEY: 13,
Expand Down

0 comments on commit cd677b1

Please sign in to comment.