MCPcopy
hub / github.com/callstack/react-native-paper / focusFirstDOMNode

Function focusFirstDOMNode

src/components/Menu/Menu.tsx:114–126  ·  view source on GitHub ↗
(el: View | null | undefined)

Source from the content-addressed store, hash-verified

112const DEFAULT_MODE = 'elevated';
113
114const focusFirstDOMNode = (el: View | null | undefined) => {
115 if (el && Platform.OS === 'web') {
116 // When in the browser, we want to focus the first focusable item on toggle
117 // For example, when menu is shown, focus the first item in the menu
118 // And when menu is dismissed, send focus back to the button to resume tabbing
119 if (el instanceof HTMLElement) {
120 el.querySelector<HTMLElement>(
121 // This is a rough list of selectors that can be focused
122 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
123 )?.focus();
124 }
125 }
126};
127
128const isCoordinate = (anchor: any): anchor is { x: number; y: number } =>
129 !React.isValidElement(anchor) &&

Callers 1

MenuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…