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

Function onBlur

packages/react-aria/src/utils/useViewportSize.ts:53–70  ·  view source on GitHub ↗
(e: FocusEvent)

Source from the content-addressed store, hash-verified

51 // We can anticipate this and resize early by handling the blur event and using the layout size.
52 let frame: number;
53 let onBlur = (e: FocusEvent) => {
54 if (visualViewport && visualViewport.scale > 1) {
55 return;
56 }
57
58 if (willOpenKeyboard(getEventTarget(e) as Element)) {
59 // Wait one frame to see if a new element gets focused.
60 frame = requestAnimationFrame(() => {
61 let activeElement = getActiveElement();
62 if (!activeElement || !willOpenKeyboard(activeElement)) {
63 updateSize({
64 width: document.documentElement.clientWidth,
65 height: document.documentElement.clientHeight
66 });
67 }
68 });
69 }
70 };
71
72 updateSize(getViewportSize());
73

Callers

nothing calls this directly

Calls 4

willOpenKeyboardFunction · 0.90
getEventTargetFunction · 0.90
getActiveElementFunction · 0.90
updateSizeFunction · 0.85

Tested by

no test coverage detected