Skip to content

Commit dd56bb0

Browse files
sbuggaymeta-codesync[bot]
authored andcommitted
Improve ReactDevToolsOverlay usability (#55387)
Summary: Pull Request resolved: #55387 The components selector on desktop has a couple of issues: - Closest public handle is very frequently null (no matching component in the React tree) meaning that nothing gets selected. Ideally we should select the closest parent. - After any selection is made, the inspector is turned off. This combined with the above problem causes the inspector to look like it fails in the vast majority of cases. For now, let's disable the behavior of toggling off the inspector when something is selected, and instead require the user to manually disable the component selector. This also changes the behavior of the overlay for all other platforms. I do think this is better UX (I've had similar issues to this on mobile.) Ultimately we should improve the component selector to be as good as the one in Inspector.js, but this seems like a good stop-gap for now. Changelog: [Internal] Reviewed By: yannickl, shwanton Differential Revision: D91913370 fbshipit-source-id: c676c4be78eebea54003a40d7cc23876f7a6b67e
1 parent 7ff4c21 commit dd56bb0

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

packages/react-native/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ export default function ReactDevToolsOverlay({
5252

5353
function onStartInspectingNative() {
5454
setIsInspecting(true);
55+
setInspected(null);
5556
}
5657

5758
function onStopInspectingNative() {
5859
setIsInspecting(false);
60+
setInspected(null);
5961
}
6062

6163
reactDevToolsAgent.addListener('shutdown', cleanup);
@@ -93,12 +95,6 @@ export default function ReactDevToolsOverlay({
9395
[inspectedViewRef, reactDevToolsAgent],
9496
);
9597

96-
const stopInspecting = useCallback(() => {
97-
reactDevToolsAgent.stopInspectingNative(true);
98-
setIsInspecting(false);
99-
setInspected(null);
100-
}, [reactDevToolsAgent]);
101-
10298
const onPointerMove = useCallback(
10399
(e: PointerEvent) => {
104100
findViewForLocation(e.nativeEvent.x, e.nativeEvent.y);
@@ -133,12 +129,10 @@ export default function ReactDevToolsOverlay({
133129
? {
134130
onPointerMove,
135131
onPointerDown: onPointerMove,
136-
onPointerUp: stopInspecting,
137132
}
138133
: {
139134
onStartShouldSetResponder: shouldSetResponder,
140135
onResponderMove: onResponderMove,
141-
onResponderRelease: stopInspecting,
142136
};
143137

144138
return (

0 commit comments

Comments
 (0)