MCPcopy Create free account
hub / github.com/adobe/react-spectrum / open

Function open

packages/react-aria/src/menu/useMenuTrigger.ts:63–72  ·  view source on GitHub ↗
(
    shouldOpen: boolean,
    e: KeyboardEvent,
    focusStrategy: FocusStrategy = 'first'
  )

Source from the content-addressed store, hash-verified

61 let {triggerProps, overlayProps} = useOverlayTrigger({type}, state, ref);
62
63 let open = (
64 shouldOpen: boolean,
65 e: KeyboardEvent,
66 focusStrategy: FocusStrategy = 'first'
67 ): boolean | void => {
68 if (!shouldOpen || e.isDefaultPrevented()) {
69 return false;
70 }
71 state.toggle(focusStrategy);
72 };
73
74 // React puts listeners on the same root, so even if propagation was stopped, immediate propagation is still possible.
75 // useTypeSelect will handle the spacebar first if it's running, so we don't want to open if it's handled it already.

Callers 5

useMenuTriggerFunction · 0.70
getSyntheticLinkFunction · 0.50
SearchMenuTriggerFunction · 0.50
handleKeyDownFunction · 0.50
handleCustomEventFunction · 0.50

Calls 1

toggleMethod · 0.65

Tested by

no test coverage detected