Skip to content

Commit

Permalink
fix: onEscKeyDown behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
EnMod committed Sep 6, 2024
1 parent 0a2b19f commit 2c12856
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ const NavigationHeaderDropdownMenu = ({
useOnFocusOutside([menuRef], () => setIsOpen(false), isOpen)

// Handles closing the menu if Esc is pressed while navigating with a keyboard and the menu is focused.
useOnEscapeKeyDown([menuRef], () => setIsOpen(false), isOpen)
useOnEscapeKeyDown(
[menuRef],
() => {
setIsOpen(false)
activatorButtonRef.current.focus()
},
isOpen
)

// Check for a visible icon or label
if (!label && !hasLeadingIcon) {
Expand Down

0 comments on commit 2c12856

Please sign in to comment.