Skip to content

Commit

Permalink
Merge pull request #147 from element-hq/florianduros/fix-menu-focus
Browse files Browse the repository at this point in the history
Fix `Menu` focus after closing
  • Loading branch information
florianduros authored Feb 7, 2024
2 parents 3942474 + 7ad68aa commit 20c6f91
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,17 @@ export const Menu: FC<Props> = ({
<Root open={open} onOpenChange={onOpenChange}>
<Trigger asChild>{trigger}</Trigger>
<Portal>
<Content asChild side={side} align={align} sideOffset={8}>
<Content
asChild
side={side}
align={align}
sideOffset={8}
onCloseAutoFocus={(event) => {
// https://www.radix-ui.com/primitives/docs/components/dropdown-menu#content => onCloseAutoFocus
// Prevent the default behavior of focusing the trigger when the menu closes
event.preventDefault();
}}
>
<FloatingMenu title={title}>{children}</FloatingMenu>
</Content>
</Portal>
Expand Down

0 comments on commit 20c6f91

Please sign in to comment.