fix(cache): hand off when the placed pixel also lies in an overlapping look-alike (ENG-1556)

Among same-named controls, the recorded point picks the one box that
holds it, and the pixel sent is the recorded place inside that box. That
pixel could lie inside a sibling that overlaps the picked box, where the
one on top receives the input. The rule beside it already hands off when
the recorded point itself lies in two overlapping siblings; the pixel sent
now gets the same check. A look-alike nested inside the picked box still
counts as the same control.

Review: kdy1 on #2395 (thread 4734170548).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
michal-e2e
2026-12-01 15:32:21 +01:00
co-authored by Claude Opus 5.5
parent 726913e1cb
commit 741287b73a
3 changed files with 28 additions and 2 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@e2e-dev/core': patch
---
Cached taps, hovers, and drags at a point recorded inside a control wait until the point lands inside that control on screen, so a drag waits for a late or hidden drop target, and a drag that waits for one end stops if a control named like the other end appears on screen or leaves it meanwhile.
Cached taps, hovers, and drags at a point recorded inside a control wait until the point lands inside that control on screen, so a drag waits for a late or hidden drop target, and a drag that waits for one end stops if a control named like the other end appears on screen or leaves it meanwhile. A point placed inside one of several same-named controls hands off when a sibling overlaps it at that pixel.
+11 -1
View File
@@ -760,7 +760,17 @@ function placeWithin(
const containing = relocated.candidates
.map((id) => visibleBox(nodes.get(id)))
.filter((box): box is Box => box !== undefined && containsPoint(box, planned.point));
if (containing.length === 1) return inside(containing[0]!, viewport);
if (containing.length === 1) {
const picked = containing[0]!;
const at = inside(picked, viewport);
if (at === undefined) return undefined;
// The pixel sent must land in the picked look-alike alone, or in one nested inside it: a sibling that overlaps it there may be on top.
const kept = clampToViewport(at, viewport);
const overlapped = relocated.candidates
.map((id) => visibleBox(nodes.get(id)))
.some((box) => box !== undefined && box !== picked && containsPoint(box, kept) && !containsBox(picked, box));
return overlapped ? undefined : at;
}
// Several look-alikes hold the point and nest: a host view and the view
// inside it, a group inside a group, an anonymous container among its
// kind. Whichever of them is the recorded node, the recorded point on a
@@ -261,6 +261,17 @@ describe('replayTrace: bare-point taps', () => {
expect(host.calls).not.toContain('tapAt');
});
it('hands off when the pixel placed in the look-alike the point picks also lies in a sibling that overlaps it', async () => {
// (300, 60) lies only in the left map; its middle, x 260, lies in the right one too.
const left: SemanticNode = { ref: { id: 'a', revision: 'r1' }, role: 'img', name: 'Map', rect: { x: 120, y: 0, width: 280, height: 200 } };
const right: SemanticNode = { ref: { id: 'b', revision: 'r1' }, role: 'img', name: 'Map', rect: { x: 240, y: 0, width: 200, height: 50 } };
const within = { target: { role: 'img', name: 'Map' }, fx: 0.5, fy: 0.1 };
const host = makeHost({ nodes: [left, right] });
const outcome = await replayTrace(host, trace([{ ...pin, within }]));
expect(outcome).toMatchObject({ completed: false, executed: 0, stopReason: 'target-ambiguous' });
expect(host.calls).not.toContain('tapAt');
});
it('hands off among look-alikes when the point settles nothing or the viewport changed', async () => {
const left: SemanticNode = { ref: { id: 'a', revision: 'r1' }, role: 'img', name: 'Map', rect: { x: 0, y: 0, width: 200, height: 200 } };
const right: SemanticNode = { ref: { id: 'b', revision: 'r1' }, role: 'img', name: 'Map', rect: { x: 200, y: 0, width: 200, height: 200 } };
@@ -541,6 +552,11 @@ describe('replayTrace: bare-point drags', () => {
looks: [[card, twin], [at(card, 700), twin, as(card, 'new'), lane]],
stops: 'target-ambiguous',
},
{
label: 'stops when the dispatched pixel lands where a sibling look-alike overlaps the source the point picks',
looks: [[card, twin], [at(card, 60), at(twin, 150), lane]],
stops: 'target-ambiguous',
},
{
label: 'stops when a visible drop target gains a look-alike under its recorded point while the source loads',
looks: [[hidden(card), lane], [card, at(lane, 900), as(lane, 'other')]],