Change hit test to explore all nodes

Summary:
Previously we would only consider a node hit if the nouse pos was inside every parents. There are a few reason why this isnt ideal:
1. Fragments are return 0 bounds
2. Many hierachys (particually in litho ) have nonsensical strucutres where your parent may have hieght 0, or children overflow parents bounds. Therefore it was impossible to select many nodes but unclear why

Reviewed By: lblasa

Differential Revision: D41304499

fbshipit-source-id: d75c8060f71fa0b972f136cb11258b62a9c98ebc
This commit is contained in:
Luke De Feo
2022-11-16 10:38:23 -08:00
committed by Facebook GitHub Bot
parent 53c15b2e59
commit 1d920efe10

View File

@@ -301,7 +301,8 @@ function hitTest(node: NestedNode, mouseCoordinate: Coordinate): NestedNode[] {
function hitTestRec(node: NestedNode, mouseCoordinate: Coordinate): boolean { function hitTestRec(node: NestedNode, mouseCoordinate: Coordinate): boolean {
const nodeBounds = node.bounds; const nodeBounds = node.bounds;
if (boundsContainsCoordinate(nodeBounds, mouseCoordinate)) { const thisNodeHit = boundsContainsCoordinate(nodeBounds, mouseCoordinate);
let children = node.children; let children = node.children;
if (node.activeChildIdx != null) { if (node.activeChildIdx != null) {
@@ -314,14 +315,12 @@ function hitTest(node: NestedNode, mouseCoordinate: Coordinate): NestedNode[] {
childHit = hitTestRec(child, offsetMouseCoord) || childHit; childHit = hitTestRec(child, offsetMouseCoord) || childHit;
} }
if (!childHit) { const hit = thisNodeHit && !childHit;
if (hit) {
res.push(node); res.push(node);
} }
return true; return hit;
}
return false;
} }
hitTestRec(node, mouseCoordinate); hitTestRec(node, mouseCoordinate);