Skip to content

Commit 554a373

Browse files
authored
[DevTools] Use the scrollWidth/Height for the root when the root is the documentElement (facebook#34651)
If I can scroll the document due to it overflowing, I should be able to scroll the suspense tab as much. The real rect for the root when it's the document is really the full scroll height. This doesn't fully eliminate the need to do recursive bounding boxes for the root since it's still possible to have the rects overflow. E.g. if they're currently resuspended or inside nested scrolls. ~However, maybe we should have the actual paintable root rect just be this rectangle instead of including the recursive ones.~ Actually never mind. The root really represents the Transition so it doesn't make sense to give it any specific rectangle. It's rather the whole background.
1 parent 5dd163b commit 554a373

File tree

1 file changed

+16
-1
lines changed
  • packages/react-devtools-shared/src/backend/fiber

1 file changed

+16
-1
lines changed

packages/react-devtools-shared/src/backend/fiber/renderer.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2251,8 +2251,23 @@ export function attach(
22512251
}
22522252
if (typeof instance.getClientRects === 'function') {
22532253
// DOM
2254-
const result: Array<Rect> = [];
22552254
const doc = instance.ownerDocument;
2255+
if (instance === doc.documentElement) {
2256+
// This is the document element. The size of this element is not actually
2257+
// what determines the whole scrollable area of the screen. Because any
2258+
// thing that overflows the document will also contribute to the scrollable.
2259+
// This is unlike overflow: scroll which clips those.
2260+
// Therefore, we use the scrollable size for this rect instead.
2261+
return [
2262+
{
2263+
x: 0,
2264+
y: 0,
2265+
width: instance.scrollWidth,
2266+
height: instance.scrollHeight,
2267+
},
2268+
];
2269+
}
2270+
const result: Array<Rect> = [];
22562271
const win = doc && doc.defaultView;
22572272
const scrollX = win ? win.scrollX : 0;
22582273
const scrollY = win ? win.scrollY : 0;

0 commit comments

Comments
 (0)