fix[Tree]: use selectedElementIndex as key to force re-render#31342
fix[Tree]: use selectedElementIndex as key to force re-render#31342hoxyq wants to merge 1 commit intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Ugh, this will actually reset the scrolling state of the list every time new element is selected, so we need a different approach |
|
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. |
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.
There is a feature that syncs the element selection between Elements panel and RDT Components panel.
Before this change, after the
scrollToItemis called, user is going to see the empty list, because nothing is rendered. This is becauseAutoSizerdoesn't know anything aboutFixedSizeListand that it was just scrolled.With this change, we are using
selectedItemIndexto force re-render forAutoSizer, which will consequently call children function.See https://fburl.com/workplace/gnu43nok.