focus from context menu

Summary: Add option to focus a view from the context menu.

Reviewed By: passy

Differential Revision: D15294182

fbshipit-source-id: f03db136e8365833beee3b4883d2114e98a280bd
This commit is contained in:
Daniel Büchele
2019-05-10 06:16:07 -07:00
committed by Facebook Github Bot
parent ffea42e57f
commit d6ccf74c37

View File

@@ -78,6 +78,18 @@ export default class Inspector extends Component<Props> {
?.id;
};
getAXContextMenuExtensions = () =>
this.props.ax
? [
{
label: 'Focus',
click: (id: ElementID) => {
this.props.client.call('onRequestAXFocus', {id});
},
},
]
: [];
componentDidMount() {
this.props.client.call(this.call().GET_ROOT).then((root: Element) => {
this.props.setPersistedState({
@@ -257,6 +269,7 @@ export default class Inspector extends Component<Props> {
root={this.root()}
elements={this.elements()}
focused={this.focused()}
contextMenuExtensions={this.getAXContextMenuExtensions()}
/>
) : null;
}