contextmenu_helpers.ts view source
(contextmenu: ContextmenuState, get_menu_el: () => HTMLElement | undefined, open_guard?: ContextmenuOpenGuard | undefined): (e: MouseEvent) => void import {contextmenu_create_mousedown_handler} from '@fuzdev/fuz_ui/contextmenu_helpers.js'; Creates a mousedown handler that closes the contextmenu when pressing outside of
the menu element, deferring to open_guard for presses that belong to the gesture
that opened the menu: gesture presses outside don't close, and gesture presses on the
menu arm the click blocker instead of activating the entry under the pointer.
Secondary-button presses outside the menu never close here - their own contextmenu
event resolves the menu in the roots' handlers (reopening it elsewhere, or closing it
when there's nothing to open) - with one exception: shift+rightclick, an explicit
native-menu request whose contextmenu event Firefox suppresses entirely, closes on
the press itself.
Registered on the window during the bubble phase deliberately -
consumers keep the menu open through a press by swallowing the event
(e.g. menu controller buttons that use onmousedowncapture + swallow).
get_menu_el
getter for the open menu element, if any
type () => HTMLElement | undefined
open_guard?
guard that identifies presses belonging to the gesture that opened the menu
type ContextmenuOpenGuard | undefined
optional
returns
(e: MouseEvent) => void