mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
fix(drone-airspace, perimeters): yield area clicks to cards painted on top
Drone airspace and fire perimeters select a zone or incident from any shape hit, so a quake card or magnitude label painted over one made both layers act on a single click: the quake opened its USGS page or flew to the quake while the area was selected too. Fire and vessel cards over an area did the same. The areas now stand aside when another layer's card or label is the topmost overlay entry, the rule the quake handler already follows for cards painted over its discs. Deselection and every other path are unchanged. Items of layers that never act on clicks no longer matter: the quake card and labels keep working over air-quality stations, traffic lines and OSM places.
This commit is contained in:
1 parent
f6314884f7
commit
959698cff9
6 files changed
+272
-1
No files matched your search
@@ -230,6 +230,15 @@ export function createFirePerimetersLayer({
|
||||
const picked = event.topHit;
|
||||
const incidentId = picked ? pickedIncidentId(event.drawHit) : null;
|
||||
if (incidentId) {
|
||||
// Another layer's card or label painted over the perimeter (a
|
||||
// quake's card or magnitude label, a fire card) is that layer's
|
||||
// click: under it the perimeter is background, so it stays as is.
|
||||
const top = overlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
{},
|
||||
);
|
||||
if (top && top.sourceId !== PERIMETER_OVERLAY_SOURCE_ID) return;
|
||||
abortLinkVerification();
|
||||
_selectedId = incidentId;
|
||||
publishSelectedCard();
|
||||
|
||||
@@ -243,6 +243,43 @@ test('clicking a perimeter publishes its incident card; empty space clears it',
|
||||
assert.equal(h.overlay.entries.get('fire-perimeters')?.length ?? 0, 0);
|
||||
});
|
||||
|
||||
// Another layer's card or label painted over the area (a quake's card or
|
||||
// magnitude label) is that layer's click: the area under it stands aside.
|
||||
test("another layer's overlay on top keeps a click off the area", async () => {
|
||||
let pickResult = null;
|
||||
let foreignOnTop = false;
|
||||
const h = harness(
|
||||
{ getSnapshot: async () => [row] },
|
||||
{
|
||||
pick: () => pickResult,
|
||||
// Unfiltered: the topmost entry of any source.
|
||||
cardHit: (_x, _y, options) =>
|
||||
foreignOnTop && !options?.sourceId
|
||||
? { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' }
|
||||
: null,
|
||||
},
|
||||
);
|
||||
await h.layer.update(h.viewer);
|
||||
pickResult = perimeterPick('fire-perimeter:2026-NMGNF-000123:0');
|
||||
foreignOnTop = true;
|
||||
h.clicks.handler({ position: { x: 10, y: 10 } });
|
||||
assert.equal(h.overlay.entries.get('fire-perimeters')?.length ?? 0, 0);
|
||||
// With nothing painted over it, the same click selects the area.
|
||||
foreignOnTop = false;
|
||||
h.clicks.handler({ position: { x: 10, y: 10 } });
|
||||
assert.equal(
|
||||
h.overlay.entries.get('fire-perimeters')[0].id,
|
||||
'fire-perimeter-card:2026-NMGNF-000123',
|
||||
);
|
||||
// An overlay on top never clears an existing selection either.
|
||||
foreignOnTop = true;
|
||||
h.clicks.handler({ position: { x: 10, y: 10 } });
|
||||
assert.equal(
|
||||
h.overlay.entries.get('fire-perimeters')[0].id,
|
||||
'fire-perimeter-card:2026-NMGNF-000123',
|
||||
);
|
||||
});
|
||||
|
||||
test('disable removes the click handler, pick ownership, and any card', async () => {
|
||||
const h = harness(
|
||||
{ getSnapshot: async () => [row] },
|
||||
|
||||
Reference in new issue
Block a user