MCPcopy
hub / github.com/adobe/react-spectrum / focus

Function focus

packages/react-aria/src/gridlist/useGridListItem.ts:108–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106 // focus to go to the item when the DOM node is reused for a different item in a virtualizer.
107 let keyWhenFocused = useRef<Key | null>(null);
108 let focus = () => {
109 // Don't shift focus to the row if the active element is a element within the row already
110 // (e.g. clicking on a row button)
111 if (
112 ref.current !== null &&
113 ((keyWhenFocused.current != null && node.key !== keyWhenFocused.current) ||
114 !isFocusWithin(ref.current))
115 ) {
116 focusSafely(ref.current);
117 }
118 };
119
120 let treeGridRowProps: HTMLAttributes<HTMLElement> = {};
121 let hasChildRows = props.hasChildItems;

Callers

nothing calls this directly

Calls 2

isFocusWithinFunction · 0.90
focusSafelyFunction · 0.90

Tested by

no test coverage detected