[devtools] Restore "double-click to view owners tree" functionality (#33039)
Sebastian "Sebbie" Silbermann committed
Apr 30, 2025 at 11:11 UTC
fbf29ccaa3598c6443d8d550aa406f9c6f654076
1 file changed
+11
-8
packages/react-devtools-shared/src/devtools/views/Components/TreeContext.js
+11
-8
@@ -891,19 +891,22 @@ function TreeContextController({
891
? store.getIndexOfElementID(store.lastSelectedHostInstanceElementId)
892
: null,
893
});
894
- const dispatchWrapper = useMemo(
895
- () => (action: Action) => startTransition(() => dispatch(action)),
894
+ const transitionDispatch = useMemo(
895
+ () => (action: Action) =>
896
+ startTransition(() => {
897
+ dispatch(action);
898
+ }),
899
[dispatch],
900
);
901
902
// Listen for host element selections.
903
useEffect(() => {
904
const handler = (id: Element['id']) =>
902
- dispatchWrapper({type: 'SELECT_ELEMENT_BY_ID', payload: id});
905
+ transitionDispatch({type: 'SELECT_ELEMENT_BY_ID', payload: id});
906
907
store.addListener('hostInstanceSelected', handler);
908
return () => store.removeListener('hostInstanceSelected', handler);
906
- }, [store, dispatchWrapper]);
909
+ }, [store, transitionDispatch]);
910
911
// If a newly-selected search result or inspection selection is inside of a collapsed subtree, auto expand it.
912
// This needs to be a layout effect to avoid temporarily flashing an incorrect selection.
@@ -927,7 +930,7 @@ function TreeContextController({
930
Array<number>,
931
Map<number, number>,
932
]) => {
930
- dispatchWrapper({
933
+ transitionDispatch({
934
type: 'HANDLE_STORE_MUTATION',
935
payload: [addedElementIDs, removedElementIDs],
936
});
@@ -938,7 +941,7 @@ function TreeContextController({
941
// At the moment, we can treat this as a mutation.
942
// We don't know which Elements were newly added/removed, but that should be okay in this case.
943
// It would only impact the search state, which is unlikely to exist yet at this point.
941
- dispatchWrapper({
944
+ transitionDispatch({
945
type: 'HANDLE_STORE_MUTATION',
946
payload: [[], new Map()],
947
});
@@ -946,11 +949,11 @@ function TreeContextController({
949
950
store.addListener('mutated', handleStoreMutated);
951
return () => store.removeListener('mutated', handleStoreMutated);
949
- }, [dispatchWrapper, initialRevision, store]);
952
+ }, [dispatch, initialRevision, store]);
953
954
return (
955
<TreeStateContext.Provider value={state}>
953
- <TreeDispatcherContext.Provider value={dispatchWrapper}>
956
+ <TreeDispatcherContext.Provider value={dispatch}>
957
{children}
958
</TreeDispatcherContext.Provider>
959
</TreeStateContext.Provider>