From 208559ebc9547fcc66acb19367c242b96e9219a3 Mon Sep 17 00:00:00 2001 From: XiaoYan Li Date: Fri, 19 Dec 2025 23:20:37 +0800 Subject: [PATCH 1/2] fix(RAC): use ICB size as the fallback value for visual viewport --- packages/@react-aria/utils/src/useViewportSize.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@react-aria/utils/src/useViewportSize.ts b/packages/@react-aria/utils/src/useViewportSize.ts index 30fc9d26385..3f2e54a52ce 100644 --- a/packages/@react-aria/utils/src/useViewportSize.ts +++ b/packages/@react-aria/utils/src/useViewportSize.ts @@ -55,7 +55,7 @@ export function useViewportSize(): ViewportSize { frame = requestAnimationFrame(() => { if (!document.activeElement || !willOpenKeyboard(document.activeElement)) { setSize(size => { - let newSize = {width: window.innerWidth, height: window.innerHeight}; + let newSize = {width: document.documentElement.clientWidth, height: document.documentElement.clientHeight}; if (newSize.width === size.width && newSize.height === size.height) { return size; } @@ -91,7 +91,7 @@ export function useViewportSize(): ViewportSize { function getViewportSize(): ViewportSize { return { // Multiply by the visualViewport scale to get the "natural" size, unaffected by pinch zooming. - width: visualViewport ? visualViewport.width * visualViewport.scale : window.innerWidth, - height: visualViewport ? visualViewport.height * visualViewport.scale : window.innerHeight + width: visualViewport ? visualViewport.width * visualViewport.scale : document.documentElement.clientWidth, + height: visualViewport ? visualViewport.height * visualViewport.scale : document.documentElement.clientHeight }; } From c1f1d8d541f18974235748f1ffa6403e58ed9db5 Mon Sep 17 00:00:00 2001 From: Robert Snow Date: Wed, 7 Jan 2026 17:08:16 -0800 Subject: [PATCH 2/2] fix tests after merge --- scripts/setupTests.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/setupTests.js b/scripts/setupTests.js index 9565be18aec..fedbf8c0bd3 100644 --- a/scripts/setupTests.js +++ b/scripts/setupTests.js @@ -104,8 +104,24 @@ beforeEach(() => { disconnect: () => null }); window.IntersectionObserver = mockIntersectionObserver; + + // Set document.documentElement dimensions to match jsdom's default window.innerWidth/innerHeight + // This is needed because clientWidth/clientHeight default to 0 in jsdom unless explicitly set + Object.defineProperty(document.documentElement, 'clientWidth', { + writable: true, + configurable: true, + value: 1024 + }); + Object.defineProperty(document.documentElement, 'clientHeight', { + writable: true, + configurable: true, + value: 768 + }); }); afterEach(() => { delete window.IntersectionObserver; + // Clean up the clientWidth/clientHeight properties + delete document.documentElement.clientWidth; + delete document.documentElement.clientHeight; });