Skip to content

Commit

Permalink
Add keyboard selection (#1918)
Browse files Browse the repository at this point in the history
* πŸ› Add preventDefault

* ✨ Add handleKeyPress

* Add onClick to onKeyDown

* Add setTimeout to useGlobalKeyPress in Menu

* πŸ”₯ Remove handleKeyPress form Menu.Item
  • Loading branch information
laliq committed Feb 1, 2022
1 parent e40ba21 commit 1b8f87a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/eds-core-react/src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ const MenuContainer = forwardRef<HTMLDivElement, MenuContainerProps>(

useGlobalKeyPress('Enter', () => {
if (open && onClose !== null) {
if (window.document.contains(anchorEl)) anchorEl.focus()
setTimeout(() => {
if (window.document.contains(anchorEl)) {
anchorEl.focus()
}
}, 0)
}
})

Expand Down

0 comments on commit 1b8f87a

Please sign in to comment.