Target mode

Summary: Adding a toggle to enable/disable target mode

Reviewed By: jknoxville

Differential Revision: D14100535

fbshipit-source-id: 9251f2d2f9d3013650421be62719ad5fb254e804
This commit is contained in:
Daniel Büchele
2019-02-18 04:53:54 -08:00
committed by Facebook Github Bot
parent c21875e168
commit 53f3f2d40f
2 changed files with 42 additions and 0 deletions

View File

@@ -74,6 +74,13 @@ export default class Inspector extends Component<Props> {
this.getNodes(nodes.map(n => n.id), {});
},
);
this.props.client.subscribe(
this.call().SELECT,
({path}: {path: Array<ElementID>}) => {
this.getAndExpandPath(path);
},
);
}
componentDidUpdate(prevProps: Props) {
@@ -173,6 +180,14 @@ export default class Inspector extends Component<Props> {
}
}
getAndExpandPath(path: Array<ElementID>) {
return Promise.all(path.map(id => this.getChildren(id, {}, true))).then(
() => {
this.onElementSelected(path[path.length - 1]);
},
);
}
onElementSelected = debounce((selectedKey: ElementID) => {
this.onElementHovered(selectedKey);
this.props.onSelect(selectedKey);