Skip to content

Commit

Permalink
Merge pull request #619 from Andarist/menu-button/simplify-mousedown-…
Browse files Browse the repository at this point in the history
…listener

Dont try to use .relatedTarget of the mousedown event
  • Loading branch information
Chance Strickland committed Jun 23, 2020
2 parents 98101d4 + e1a23cc commit fabb327
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 fabb327

Please sign in to comment.