[DevTools] Shrink/Deshrink Owners breadcrumbs on any resizes#466
[DevTools] Shrink/Deshrink Owners breadcrumbs on any resizes#466everettbu wants to merge 2 commits into
Conversation
Greptile OverviewGreptile SummaryThis PR updates the DevTools Hooks view breadcrumbs sizing logic to respond to layout changes beyond global window resizes by switching to a Confidence Score: 5/5
Important Files Changed
|
| const ownerWindow = container.ownerDocument.defaultView; | ||
| ownerWindow.addEventListener('resize', handleResize); | ||
| return () => ownerWindow.removeEventListener('resize', handleResize); | ||
| }, [containerRef, totalChildWidth]); | ||
| paneResizeObserver.addListener(handleResize); |
There was a problem hiding this 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).
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.|
Upstream PR was closed or merged. Code is synced via branch mirror. |
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
ResizeObservernow 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