Fix selectNode in fabric

Summary:
Changelog:
[General][Fixed] - Currently selectNode doesn't work for Fabric. Passing the instance instead of a tag to `selectNode` works.

Reviewed By: lunaruan

Differential Revision: D38851141

fbshipit-source-id: 7640d0f31fb099346a4d8205981e262da6be4990
This commit is contained in:
Tianyu Yao
2022-09-12 16:56:19 -07:00
committed by Facebook GitHub Bot
parent 2d5db284b0
commit 6163029d4a
2 changed files with 14 additions and 4 deletions
+6 -2
View File
@@ -121,8 +121,12 @@ export default function DevtoolsOverlay({
locationX,
locationY,
viewData => {
const {touchedViewTag} = viewData;
if (touchedViewTag != null) {
const {touchedViewTag, closestInstance} = viewData;
if (closestInstance != null) {
// Fabric
agent.selectNode(closestInstance);
return true;
} else if (touchedViewTag != null) {
agent.selectNode(findNodeHandle(touchedViewTag));
return true;
}
+8 -2
View File
@@ -136,13 +136,19 @@ class Inspector extends React.Component<
frame,
pointerY,
touchedViewTag,
closestInstance,
} = viewData;
// Sync the touched view with React DevTools.
// Note: This is Paper only. To support Fabric,
// DevTools needs to be updated to not rely on view tags.
if (this.state.devtoolsAgent && touchedViewTag) {
this.state.devtoolsAgent.selectNode(findNodeHandle(touchedViewTag));
if (this.state.devtoolsAgent) {
if (closestInstance != null) {
// Fabric
this.state.devtoolsAgent.selectNode(closestInstance);
} else if (touchedViewTag != null) {
this.state.devtoolsAgent.selectNode(findNodeHandle(touchedViewTag));
}
}
this.setState({