Skip to content

Commit

Permalink
Dont try to use .relatedTarget of the mousedown event
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Jun 16, 2020
1 parent a0c7b36 commit e1a23cc
Showing 1 changed file with 1 addition and 7 deletions.
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

0 comments on commit e1a23cc

Please sign in to comment.