MCPcopy Index your code
hub / github.com/adobe/react-spectrum / onPressStart

Function onPressStart

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

Source from the content-addressed store, hash-verified

116 let pressProps: PressProps = {
117 preventFocusOnPress: true,
118 onPressStart(e) {
119 // For consistency with native, open the menu on mouse/key down, but touch up.
120 if (e.pointerType !== 'touch' && e.pointerType !== 'keyboard' && !isDisabled) {
121 // Ensure trigger has focus before opening the menu so it can be restored by FocusScope on close.
122 focusWithoutScrolling(e.target as FocusableElement);
123
124 // If opened with a screen reader, auto focus the first item.
125 // Otherwise, the menu itself will be focused.
126 state.open(e.pointerType === 'virtual' ? 'first' : null);
127 }
128 },
129 onPress(e) {
130 if (e.pointerType === 'touch' && !isDisabled) {
131 // 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