fix(overlays): let only the topmost painted card act on a click

Card handlers hit-tested only their own source, so a card buried under
another layer's card still acted, and a click on a selected quake card over
a vessel or fire card made both layers act. Vessels, FIRMS, wildlife, news,
ghost maps and shipwrecks now read the unfiltered topmost painted entry:
their own card acts only when it is on top, and a click on another layer's
card is that layer's, so it neither acts here nor clears a selection.

A top news or wildlife card still acts over another layer's scene item, so
it never goes dead over a flight trail or a directions route; a registered
marker under a foreign card is still its layer's to select.
This commit is contained in:
manjunath22466 committed 2026-11-17 01:32:47 +05:30
1 parent 5bc31ce08a
commit 836daf82b3
14 files changed
+310 -43

No files matched your search

@@ -21,6 +21,7 @@ function fixture(sighting = row, extraServices = {}) {
const seen = [];
const painted = new Set();
let hit = null;
let coveringHit = null;
let projections = 0;
let click;
const state = {
@@ -49,8 +50,12 @@ function fixture(sighting = row, extraServices = {}) {
setEntries: (id, value) => entries.set(id, value),
clearSource: (id) => entries.delete(id),
setVisible() {},
hitTest: (_x, _y, { sourceId }) =>
hit?.sourceId === sourceId ? hit : null,
hitTest: (_x, _y, { sourceId } = {}) =>
sourceId
? hit?.sourceId === sourceId
? hit
: null
: coveringHit || hit,
},
now: () => row.observedAt + 60_000,
project: (_scene, anchor) => {
@@ -94,6 +99,9 @@ function fixture(sighting = row, extraServices = {}) {
?.find((entry) => entry.id === entryId);
hit = entry ? { sourceId, entryId, entry } : null;
},
cover(value) {
coveringHit = value;
},
paint(ids) {
painted.clear();
for (const id of ids) painted.add(id);
@@ -179,6 +187,37 @@ test('selected photo and name cards use the selected lane, select on click and n
}
});
test('a covered sighting label yields; the top label acts over trails and other scene items', () => {
const f = fixture(row, {
// Registered owners, as the app has them: an aircraft, and the flight
// trails every layer reads as a no-op (src/data/trailRenderer.js).
picking: {
isOwnedByOtherLayer: (_layer, id) =>
id === 'other:aircraft' || String(id).startsWith('gev-trail:'),
},
});
f.selection.install();
f.selection.refreshAmbient();
f.hit('wildlife-sightings-labels', 'wildlife-sightings-label:inat:123');
f.click(null);
assert.equal(f.flights.length, 1);
f.cover({ sourceId: 'earthquakes', entryId: 'quake:cover' });
f.click(null);
assert.equal(f.flights.length, 1);
assert.equal(f.state.selectedRow, row);
f.click();
assert.equal(f.flights.length, 2, 'an actual sighting remains selectable');
f.cover(null);
// The top label acts over a flight trail: never a dead click.
f.click('gev-trail:fl-a1b2c3:head');
assert.equal(f.flights.length, 3, 'the label acts over a flight trail');
// And over another layer's scene item, as on main.
f.click('other:aircraft');
assert.equal(f.flights.length, 4, 'the top label acts');
assert.equal(f.state.selectedRow, row);
f.selection.remove();
});
test('nearby duplicate display names yield to painted cards and higher-ranked labels using cached screens', () => {
const low = {
...row,