Skip to content

Conversation

hoxyq
Copy link
Contributor

@hoxyq hoxyq commented Oct 24, 2024

There is a feature that syncs the element selection between Elements panel and RDT Components panel.

Before this change, after the scrollToItem is called, user is going to see the empty list, because nothing is rendered. This is because AutoSizer doesn't know anything about FixedSizeList and that it was just scrolled.

With this change, we are using selectedItemIndex to force re-render for AutoSizer, which will consequently call children function.

See https://fburl.com/workplace/gnu43nok.

Copy link

vercel bot commented Oct 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 24, 2024 2:41pm

@hoxyq
Copy link
Contributor Author

hoxyq commented Oct 24, 2024

Ugh, this will actually reset the scrolling state of the list every time new element is selected, so we need a different approach

@gaearon
Copy link
Collaborator

gaearon commented Oct 30, 2024

not sure if this has anything to do with the issue you're fixing, but wanted to note it's pretty frustrating that the first time I open the Components tab, its scroll position isn't synced to the DOM selection — so i have to "find" the element again. i beileve this used to work in the distant past

@hoxyq
Copy link
Contributor Author

hoxyq commented Nov 1, 2024

not sure if this has anything to do with the issue you're fixing, but wanted to note it's pretty frustrating that the first time I open the Components tab, its scroll position isn't synced to the DOM selection — so i have to "find" the element again. i beileve this used to work in the distant past

Yeah, this is one of the things I am fixing. I am currently on leave, but planning to get this fixed once I am back in December.

hoxyq added a commit that referenced this pull request Jan 9, 2025
Related: #31342

This fixes RDT behaviour when some DOM element was pre-selected in
built-in browser's Elements panel, and then Components panel of React
DevTools was opened for the first time. With this change, React DevTools
will correctly display the initial state of the Components Tree with the
corresponding React Element (if possible) pre-selected.

Previously, we would only subscribe listener when `TreeContext` is
mounted, but this only happens when user opens one of React DevTools
panels for the first time. With this change, we keep state inside
`Store`, which is created when Browser DevTools are opened. Later,
`TreeContext` will use it for initial state value.

Planned next changes:
1. Merge `inspectedElementID` and `selectedElementID`, I have no idea
why we need both.
2. Fix issue with `AutoSizer` rendering a blank container.
@hoxyq hoxyq closed this Jan 9, 2025
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.

4 participants