Skip to content

Commit

Permalink
fix(MenuList): emit click event on keydown
Browse files Browse the repository at this point in the history
  • Loading branch information
LexSwed committed Oct 4, 2020
1 parent f7c8bcc commit 0d4424e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/lib/Menu/MenuList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ function useMenuProps({ placement = 'bottom-start', offset = 8, ...props }: Prop

const selectItem = useCallback(
(li: HTMLLIElement) => {
if (!onAction) return;
const action = stateRef.current.items.get(li)?.action;
if (action) {
onAction(action);
} else {
li.click();
if (onAction) {
const action = stateRef.current.items.get(li)?.action;
if (action) {
return onAction(action);
}
}
li.click();
},
[onAction, stateRef]
);
Expand Down
6 changes: 3 additions & 3 deletions src/pages/components/Menu.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ You can modify `offset` and [`placement`](https://popper.js.org/docs/v2/construc
<Playground>
<ThemeProvider theme="black">
<Box css={{ p: '$8' }}>
<Menu onAction={typeof window !== 'undefined' ? window.alert : null}>
<Menu>
<Menu.Button>
<span>Open menu</span>
<Icon as={HiChevronDown} size="lg" />
</Menu.Button>
<Menu.List offset={0} placement="right-start">
{Array(500)
{Array(20)
.fill(null)
.map((el, i) => (
<Menu.Item key={i} action={`Item ${i}`}>
<Menu.Item key={i} onClick={() => window.alert(i)}>
Item {i}
</Menu.Item>
))}
Expand Down

1 comment on commit 0d4424e

@vercel
Copy link

@vercel vercel bot commented on 0d4424e Oct 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.