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

Function onPressStart

packages/react-aria/src/menu/useMenuTrigger.ts:125–135  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

123 let pressProps: PressProps = {
124 preventFocusOnPress: true,
125 onPressStart(e) {
126 // For consistency with native, open the menu on mouse/key down, but touch up.
127 if (e.pointerType !== 'touch' && e.pointerType !== 'keyboard' && !isDisabled) {
128 // Ensure trigger has focus before opening the menu so it can be restored by FocusScope on close.
129 focusWithoutScrolling(e.target as FocusableElement);
130
131 // If opened with a screen reader, auto focus the first item.
132 // Otherwise, the menu itself will be focused.
133 state.open(e.pointerType === 'virtual' ? 'first' : null);
134 }
135 },
136 onPress(e) {
137 if (e.pointerType === 'touch' && !isDisabled) {
138 // Ensure trigger has focus before opening the menu so it can be restored by FocusScope on close.

Callers

nothing calls this directly

Calls 2

focusWithoutScrollingFunction · 0.90
openMethod · 0.65

Tested by

no test coverage detected