From d28748e69f8eb8a53a9ff065a6a6bb98b05d2357 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Fri, 17 Feb 2023 02:45:05 -0800 Subject: [PATCH] Dont allow focusing nodes with zero area Summary: If you focused a node with zero area (e.g a fragment) it would make the visualiser disappear. Simple solution is to prevent this in this case Reviewed By: mweststrate Differential Revision: D43363219 fbshipit-source-id: 8035db47486a2872fd86a5336e9fcaabeb0016a6 --- .../public/ui-debugger/components/Tree.tsx | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/desktop/plugins/public/ui-debugger/components/Tree.tsx b/desktop/plugins/public/ui-debugger/components/Tree.tsx index 5cfc1db63..396344a26 100644 --- a/desktop/plugins/public/ui-debugger/components/Tree.tsx +++ b/desktop/plugins/public/ui-debugger/components/Tree.tsx @@ -435,8 +435,8 @@ const ContextMenu: React.FC<{ }) => { const copyItems: ReactNode[] = []; const hoveredNode = nodes.get(hoveredNodeId ?? Number.MAX_SAFE_INTEGER); + if (hoveredNode) { - copyItems.push(); copyItems.push( { + onFocusNode(hoveredNodeId); + }} + /> + ); + + const removeFocus = focusedNodeId && ( + { + onFocusNode(undefined); + }} + /> + ); return ( { @@ -466,25 +488,9 @@ const ContextMenu: React.FC<{ }} overlay={() => ( - {hoveredNode != null && focusedNodeId !== hoveredNodeId && ( - { - onFocusNode(hoveredNodeId); - }} - /> - )} - - {focusedNodeId && ( - { - onFocusNode(undefined); - }} - /> - )} + {focus} + {removeFocus} + {(focus || removeFocus) && } {copyItems} )}