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

Function onTriggerFocus

packages/react-aria/src/tooltip/usePreviewTrigger.ts:143–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141 };
142
143 let onTriggerFocus = e => {
144 if (ignoreFocus.current) {
145 ignoreFocus.current = false;
146 return;
147 }
148
149 // Prevent browser focusing the link on long press when focus is already in the popover.
150 if (state.isOpen && e.relatedTarget === popoverRef.current) {
151 focusWithoutScrolling(popoverRef.current as FocusableElement);
152 return;
153 }
154
155 if (isFocusVisible.current) {
156 // Open after the warmup delay on keyboard focus, not immediately like a tooltip. This way
157 // tabbing quickly through the page doesn't open previews (and add their tab stops); the
158 // delay ensures the user is actually interested in the link's details.
159 state.open();
160 }
161 };
162
163 useEvent(triggerRef, 'react-aria-focus-scope-restore', e => {
164 e.preventDefault();

Callers

nothing calls this directly

Calls 2

focusWithoutScrollingFunction · 0.90
openMethod · 0.65

Tested by

no test coverage detected