Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont try to use .relatedTarget of the mousedown event #619

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions packages/menu-button/src/index.tsx
Expand Up @@ -879,15 +879,9 @@ export const MenuPopover = forwardRef<any, MenuPopoverProps>(
if (buttonClickedRef.current) {
buttonClickedRef.current = false;
} else {
let { relatedTarget, target } = event;

// We on want to close only if focus rests outside the menu
if (isExpanded && popoverRef.current) {
if (
!popoverRef.current?.contains(
(relatedTarget || target) as Element
)
) {
if (!popoverRef.current.contains(event.target as Element)) {
dispatch({ type: CLOSE_MENU, payload: { buttonRef } });
}
}
Expand Down