Skip to content

Commit

Permalink
fix: close Menu/Popover on right click
Browse files Browse the repository at this point in the history
fix #117
  • Loading branch information
jedwards1211 committed Mar 13, 2023
1 parent ef25986 commit 5f4e1af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/hooks.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ declare export function bindPopover(popupState: PopupState): {|
open: boolean,
onClose: () => void,
onMouseLeave: (event: SyntheticMouseEvent<>) => void,
onContextMenu: (event: SyntheticMouseEvent<>) => void,
disableAutoFocus?: boolean,
disableEnforceFocus?: boolean,
disableRestoreFocus?: boolean,
Expand All @@ -166,6 +167,7 @@ declare export function bindMenu(popupState: PopupState): {|
open: boolean,
onClose: () => void,
onMouseLeave: (event: SyntheticMouseEvent<>) => void,
onContextMenu: (event: SyntheticMouseEvent<>) => void,
autoFocus?: boolean,
disableAutoFocusItem?: boolean,
disableAutoFocus?: boolean,
Expand Down
10 changes: 10 additions & 0 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ export function bindPopover({
open: boolean
onClose: () => void
onMouseLeave: (event: MouseEvent) => void
onContextMenu: (event: MouseEvent) => void
disableAutoFocus?: boolean
disableEnforceFocus?: boolean
disableRestoreFocus?: boolean
Expand All @@ -482,6 +483,10 @@ export function bindPopover({
open: isOpen,
onClose: close,
onMouseLeave,
onContextMenu: (e: MouseEvent) => {
e.preventDefault()
close()
},
...(disableAutoFocus && {
disableAutoFocus: true,
disableEnforceFocus: true,
Expand Down Expand Up @@ -520,6 +525,7 @@ export function bindMenu({
open: boolean
onClose: () => void
onMouseLeave: (event: MouseEvent) => void
onContextMenu: (event: MouseEvent) => void
autoFocus?: boolean
disableAutoFocusItem?: boolean
disableAutoFocus?: boolean
Expand All @@ -535,6 +541,10 @@ export function bindMenu({
open: isOpen,
onClose: close,
onMouseLeave,
onContextMenu: (e: MouseEvent) => {
e.preventDefault()
close()
},
...(disableAutoFocus && {
autoFocus: false,
disableAutoFocusItem: true,
Expand Down

0 comments on commit 5f4e1af

Please sign in to comment.