From 129c848b78dbf2a7fef3632b5d06418952e4e2a7 Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Tue, 1 Aug 2023 10:32:29 -0700 Subject: [PATCH] Fixed bug where target mode would contain parents of hit nodes Summary: The idea of the hit test is to return the deepest children that hit an element and not their parents. Due to this bug we were actually returning every other node all the way up to the root resulting in way to many hit nodes for target mode Reviewed By: lblasa Differential Revision: D47949837 fbshipit-source-id: d3391b4a700ab0be4c3b21dde5f13452f90c887b --- .../components/visualizer/Visualization2D.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx b/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx index 2d92469d6..15d07ee67 100644 --- a/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx +++ b/desktop/plugins/public/ui-debugger/components/visualizer/Visualization2D.tsx @@ -530,18 +530,19 @@ function hitTest(node: NestedNode, mouseCoordinate: Coordinate): NestedNode[] { children = [node.children[node.activeChildIdx]]; } const offsetMouseCoord = offsetCoordinate(mouseCoordinate, nodeBounds); - let childHit = false; + let anyChildHitRecursive = false; for (const child of children) { - childHit = hitTestRec(child, offsetMouseCoord) || childHit; + anyChildHitRecursive = + hitTestRec(child, offsetMouseCoord) || anyChildHitRecursive; } - const hit = thisNodeHit && !childHit; + const hit = thisNodeHit && !anyChildHitRecursive; if (hit) { res.push(node); } - return hit; + return thisNodeHit || anyChildHitRecursive; } hitTestRec(node, mouseCoordinate);