mirror of
https://github.com/facebook/sapling.git
synced 2024-10-04 22:07:44 +03:00
Don't show context menu if there's no items
Summary: If the creator callback to useContextMenu returns `[]`, don't show a blank context menu. Instead, return. This also skips the stopPropagation, so parent context menu handlers can be used. In practice, this is used for right clicking on a remote bookmark to not show a menu, and instead continue to delegate to `<Commit>`'s context menu. Reviewed By: quark-zju Differential Revision: D55938828 fbshipit-source-id: 25e43136a76c4efeb26c89e5c818380e1d4991c1
This commit is contained in:
parent
aa6fa5a662
commit
dd30de9bb2
@ -32,7 +32,11 @@ export function useContextMenu<T>(
|
||||
const setState = useSetAtom(contextMenuState);
|
||||
return e => {
|
||||
const zoom = getZoomLevel();
|
||||
setState({x: e.clientX / zoom, y: e.clientY / zoom, items: creator()});
|
||||
const items = creator();
|
||||
if (items.length === 0) {
|
||||
return;
|
||||
}
|
||||
setState({x: e.clientX / zoom, y: e.clientY / zoom, items});
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
Loading…
Reference in New Issue
Block a user