MCPcopy Create free account
hub / github.com/ReactTooltip/react-tooltip / isWindowRestoredFocus

Function isWindowRestoredFocus

src/components/Tooltip/focus-open.ts:133–147  ·  view source on GitHub ↗
(target: EventTarget | null)

Source from the content-addressed store, hash-verified

131}
132
133export function isWindowRestoredFocus(target: EventTarget | null): boolean {
134 if (!(target instanceof Node) || restoredFocusElement === null) {
135 return false
136 }
137 const restored = target === restoredFocusElement || restoredFocusElement.contains(target)
138 if (!restored) {
139 // The user focused something else, so this was not a window restore.
140 scheduleClearRestoredFocus()
141 return false
142 }
143 // Keep the record until the next turn so every tooltip handler for this
144 // event sees it, including when the browser never fires window focus.
145 scheduleClearRestoredFocus()
146 return true
147}
148
149export function shouldOpenOnVisibleFocus(event: Event): boolean {
150 const { target } = event

Callers 1

useTooltipEventsFunction · 0.90

Calls 1

Tested by

no test coverage detected