Skip to content

[DevTools] Shrink/Deshrink Owners breadcrumbs on any resizes#466

Closed
everettbu wants to merge 2 commits into
mainfrom
sebbie/02-04-_devtools_shrink/deshrink_owners_breadcrumbs_on_all_resizes
Closed

[DevTools] Shrink/Deshrink Owners breadcrumbs on any resizes#466
everettbu wants to merge 2 commits into
mainfrom
sebbie/02-04-_devtools_shrink/deshrink_owners_breadcrumbs_on_all_resizes

Conversation

@everettbu

@everettbu everettbu commented Feb 4, 2026

Copy link
Copy Markdown

Mirror of facebook/react#35694
Original author: eps1lon


Summary

We only recalculated the size when the window resizes. However, resize also happens when the inner panes are resized. Deep owner tree took up all the space since resizing wasn't possible anymore.

We use ResizeObserver now to cover all cases triggering a resize.

How did you test this change?

Before:

CleanShot.2026-02-04.at.22.55.29.mp4

After:

CleanShot.2026-02-04.at.22.48.04.mp4

@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 4, 2026
@greptile-apps

greptile-apps Bot commented Feb 4, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR updates the DevTools Hooks view breadcrumbs sizing logic to respond to layout changes beyond global window resizes by switching to a ResizeObserver. This ensures deep owner trees can reflow/shrink correctly when inner panes (not just the window) are resized, keeping the breadcrumbs usable during DevTools panel resizing.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is localized to the breadcrumbs sizing behavior and uses standard ResizeObserver semantics; no additional definite runtime or logic issues were found in the modified code beyond an already-reported guard needed for defaultView === null.
  • packages/react-devtools-shared/src/devtools/views/hooks.js

Important Files Changed

Filename Overview
packages/react-devtools-shared/src/devtools/views/hooks.js Replaces window resize listener with a ResizeObserver to recalculate breadcrumbs size on any pane/element resize; no additional correctness issues found beyond the already-noted null defaultView case.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +146 to +148
const ownerWindow = container.ownerDocument.defaultView;
ownerWindow.addEventListener('resize', handleResize);
return () => ownerWindow.removeEventListener('resize', handleResize);
}, [containerRef, totalChildWidth]);
paneResizeObserver.addListener(handleResize);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Null ownerWindow crash

container.ownerDocument.defaultView can be null (e.g. detached document, certain iframe/extension contexts). In that case ownerWindow.addEventListener('resize', ...) will throw and break the hook. Consider guarding against defaultView === null before adding/removing the listener (and still registering the pane resize listener if applicable).

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/react-devtools-shared/src/devtools/views/hooks.js
Line: 146:148

Comment:
**Null ownerWindow crash**

`container.ownerDocument.defaultView` can be `null` (e.g. detached document, certain iframe/extension contexts). In that case `ownerWindow.addEventListener('resize', ...)` will throw and break the hook. Consider guarding against `defaultView === null` before adding/removing the listener (and still registering the pane resize listener if applicable).

How can I resolve this? If you propose a fix, please make it concise.

@everettbu everettbu changed the title [DevTools] Shrink/Deshrink Owners breadcrumbs on pane resizes [DevTools] Shrink/Deshrink Owners breadcrumbs on any resizes Feb 5, 2026

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Feb 5, 2026
@everettbu
everettbu deleted the sebbie/02-04-_devtools_shrink/deshrink_owners_breadcrumbs_on_all_resizes branch February 5, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants