Skip to content

Commit

Permalink
[@mantine/core] Menu: Fix onKeyDown prop not working in Menu.Dropdo…
Browse files Browse the repository at this point in the history
…wn component (#6910)
  • Loading branch information
Meierschlumpf authored Sep 30, 2024
1 parent 0f0b871 commit 397e782
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,22 @@ export const MenuDropdown = factory<MenuDropdownFactory>((props, ref) => {
vars,
onMouseEnter,
onMouseLeave,
onKeyDown,
children,
...others
} = useProps('MenuDropdown', defaultProps, props);

const wrapperRef = useRef<HTMLDivElement>(null);
const ctx = useMenuContext();

const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
const handleKeyDown = createEventHandler<any>(onKeyDown, (event) => {
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
event.preventDefault();
wrapperRef.current
?.querySelectorAll<HTMLButtonElement>('[data-menu-item]:not(:disabled)')[0]
?.focus();
}
};
});

const handleMouseEnter = createEventHandler<any>(
onMouseEnter,
Expand Down

0 comments on commit 397e782

Please sign in to comment.