fix(click): the card or label on top takes the click in every layer

Review fixes for #1781:

- One rule for cards: the world-overlay host hands its hit test to the
  pick registry, and every click handler reads the topmost interactive
  card or label once per click (`clickCard`, `isUnderOtherCard` in
  src/data/pickRegistry.js), so all handlers agree in any listener order.
  A layer whose own card or label is on top acts on it whatever is drawn
  under it; a layer under another layer's card neither acts nor treats
  the click as empty space (a tracked aircraft stays tracked, a selection
  stays selected); Context names nothing under a card. A selected news
  card over a vessel no longer opens the link and selects the vessel.
- With one rule, the per-owner arbitration options are no longer read
  and are removed: `passive`, `expanded` and `declinesClick` pick owners,
  `rememberClickPickActions`, `isActedOnByOtherLayer`, card backgrounds
  and `cardKeepsClick`. The dispatcher is unchanged from main.
- A drag that ends on a quake disc, label or card does nothing; opening
  the USGS page or clearing the selection needs a clean click.
- A click on the map under another layer's card opens no Street Level
  ground image.
- A CCTV card that is going away is still not the scene under it.
- Docs and changelog describe the new rule.
This commit is contained in:
Sameh Khamis committed 2026-11-18 18:23:41 -08:00
1 parent 7312280817
commit bb3bf9858b
87 files changed
+1398 -1775

No files matched your search

+12 -17
View File
@@ -215,25 +215,21 @@ export function createFirePerimetersLayer({
// so claiming these large ground polygons would make FIRMS/vessel/CCTV
// cards inert anywhere over a perimeter. Unowned, our picks read as
// "empty space" to siblings — the pre-existing behavior for the globe.
// Our shapes stand aside for a card painted over them (below), so that
// card's layer may act on the click; without a hit-test they cannot.
if (overlayHost?.hitTest)
picking?.registerCardBackground?.(
layer.id,
(hit) => pickedIncidentId(hit) !== null,
);
_clickSubscription = inputFor(_viewer).onClick((event) => {
// A click on the incident card itself opens its InciWeb page (when the
// incident has one) and never disturbs the selection.
const cardHit = overlayHost.hitTest?.(
event.screenPosition?.x,
event.screenPosition?.y,
);
// Only the top painted card owns the click; this area's shapes are
// background when another layer has painted a card or label over them.
if (cardHit && cardHit.sourceId !== PERIMETER_OVERLAY_SOURCE_ID) return;
if (cardHit && cardHit.entryId === _selectedCardId) {
if (_selectedLink && openExternal) openExternal(_selectedLink);
// The card or label painted on top takes the click, read once per
// click so every layer agrees: this area's shapes are background to
// another layer's card or label painted over them.
const cardHit = picking.clickCard?.(event) ?? null;
if (cardHit) {
if (
cardHit.sourceId === PERIMETER_OVERLAY_SOURCE_ID &&
cardHit.entryId === _selectedCardId &&
_selectedLink &&
openExternal
)
openExternal(_selectedLink);
return;
}
const picked = event.topHit;
@@ -261,7 +257,6 @@ export function createFirePerimetersLayer({
function removeClickHandler() {
_clickSubscription?.();
_clickSubscription = null;
picking?.unregisterCardBackground?.(layer.id);
}
function clearSelection() {
+3 -23
View File
@@ -27,7 +27,6 @@ function harness(
) {
const overlay = { entries: new Map(), visible: null };
const owners = new Map();
const backgrounds = new Map();
const opened = [];
const viewer = { scene: { pick } };
const { draw } = bindFakeDraw(viewer);
@@ -59,9 +58,9 @@ function harness(
String(pickedId).startsWith('other-layer:'),
registerPickOwner: (layerId, predicate) => owners.set(layerId, predicate),
unregisterPickOwner: (layerId) => owners.delete(layerId),
registerCardBackground: (layerId, predicate) =>
backgrounds.set(layerId, predicate),
unregisterCardBackground: (layerId) => backgrounds.delete(layerId),
// The card on top at a click, as the registry answers from the host.
clickCard: (click) =>
cardHit(click.screenPosition?.x, click.screenPosition?.y, {}),
},
inciwebSource: inciwebIndex
? { getIndex: async () => inciwebIndex }
@@ -81,7 +80,6 @@ function harness(
overlay,
clicks,
owners,
backgrounds,
opened,
};
}
@@ -694,21 +692,3 @@ test('a failed refresh after a stale snapshot reads as the failure, not stale',
assert.equal(h.layer.getStats().stale, false);
assert.equal(h.layer.getStats().error, 'WFIGS HTTP 502');
});
// A card painted over the area may act there (a live CCTV card): the layer
// names its own drawn shapes, and only while it takes clicks.
test('enabled, the perimeter shapes register as card background', async () => {
const h = harness({ getSnapshot: async () => [row] });
await h.layer.update(h.viewer);
const isBackground = h.backgrounds.get('fire-perimeters');
const own = {
set: h.fills().spec.id,
id: 'fire-perimeter:2026-NMGNF-000123:0',
surface: false,
};
assert.equal(isBackground(own), true);
assert.equal(isBackground({ ...own, set: 'other:1:fills' }), false);
assert.equal(isBackground({ ...own, id: 'other-layer:x' }), false);
h.layer.disable(h.viewer);
assert.equal(h.backgrounds.has('fire-perimeters'), false);
});