Skip to content

Commit

Permalink
fix: click on inputs that are not contained within dropdown-menu prev…
Browse files Browse the repository at this point in the history
…ent dropdown from closing
  • Loading branch information
alpadev committed May 10, 2021
1 parent 9d6d0d6 commit 55ff527
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions js/src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,8 @@ class Dropdown extends BaseComponent {
}

static clearMenus(event) {
if (event) {
if (event.button === RIGHT_MOUSE_BUTTON || (event.type === 'keyup' && event.key !== TAB_KEY)) {
return
}

if (/input|select|option|textarea|form/i.test(event.target.tagName)) {
return
}
if (event && (event.button === RIGHT_MOUSE_BUTTON || (event.type === 'keyup' && event.key !== TAB_KEY))) {
return
}

const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE)
Expand Down Expand Up @@ -448,8 +442,8 @@ class Dropdown extends BaseComponent {
continue
}

// Tab navigation through the dropdown menu shouldn't close the menu
if (event.type === 'keyup' && event.key === TAB_KEY && context._menu.contains(event.target)) {
// Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
if (context._menu.contains(event.target) && ((event.type === 'keyup' && event.key === TAB_KEY) || /input|select|option|textarea|form/i.test(event.target.tagName))) {
continue
}

Expand Down

0 comments on commit 55ff527

Please sign in to comment.