From e7e5e67baf8f0d1b7e040e4351366add44034a6a Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Mon, 29 Sep 2025 15:14:17 -0400 Subject: [PATCH] Use the scrollWidth/Height for the root when the root is the documentElement --- .../src/backend/fiber/renderer.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/react-devtools-shared/src/backend/fiber/renderer.js b/packages/react-devtools-shared/src/backend/fiber/renderer.js index 0dd3084af5a..cde4a589494 100644 --- a/packages/react-devtools-shared/src/backend/fiber/renderer.js +++ b/packages/react-devtools-shared/src/backend/fiber/renderer.js @@ -2251,8 +2251,23 @@ export function attach( } if (typeof instance.getClientRects === 'function') { // DOM - const result: Array = []; const doc = instance.ownerDocument; + if (instance === doc.documentElement) { + // This is the document element. The size of this element is not actually + // what determines the whole scrollable area of the screen. Because any + // thing that overflows the document will also contribute to the scrollable. + // This is unlike overflow: scroll which clips those. + // Therefore, we use the scrollable size for this rect instead. + return [ + { + x: 0, + y: 0, + width: instance.scrollWidth, + height: instance.scrollHeight, + }, + ]; + } + const result: Array = []; const win = doc && doc.defaultView; const scrollX = win ? win.scrollX : 0; const scrollY = win ? win.scrollY : 0;