Skip to content

Commit

Permalink
Fix selectNode in fabric
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tyao1 authored and facebook-github-bot committed Sep 12, 2022
1 parent 2d5db28 commit 6163029
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Libraries/Inspector/DevtoolsOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 8 additions & 2 deletions Libraries/Inspector/Inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 6163029

Please sign in to comment.