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

@@ -0,0 +1,65 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createInteraction } from './interaction.js';
import { fakeInput } from '../../input/testDoubles.mjs';
import * as picking from '../../data/pickRegistry.js';
// The card or label painted on top takes the click: a satellite under another
// layer's card is neither tracked nor let go.
test("another layer's card over a satellite keeps the click", (t) => {
const previousDocument = globalThis.document;
globalThis.document = new EventTarget();
let picked = null;
const viewer = { scene: { canvas: new EventTarget(), pick: () => picked } };
const input = fakeInput(viewer);
const calls = [];
const state = {
_enabled: true,
_trackedNorad: null,
_clickSubscription: null,
_trackedEntityChangedRemove: () => {},
_catalog: new Map([[25544, {}]]),
};
const interaction = createInteraction({
state,
services: { picking },
parts: {
rendering: {
_hitIsTracked: () => false,
_hitPointId: (hit) =>
hit?.set === 'satellites:dots' ? Number(hit.id) : null,
},
tracking: {
_cancelPendingTrackingRestore() {},
_trackSatellite: (id) => calls.push(['track', id]),
_clearTracking: () => calls.push(['clear']),
},
},
});
interaction._installClickHandler(viewer);
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
picking.setClickCardHitTest(() => top);
t.after(() => {
picking.setClickCardHitTest(null);
state._clickSubscription?.();
input.destroy();
if (previousDocument === undefined) delete globalThis.document;
else globalThis.document = previousDocument;
});
const click = (hit) => {
picked = hit ? { id: hit } : null;
input.tap({ x: 10, y: 10 });
};
const dot = { set: 'satellites:dots', id: '25544' };
click(dot);
assert.deepEqual(calls, [], 'covered: not tracked');
state._trackedNorad = 1;
click(null);
assert.deepEqual(calls, [], 'covered: tracking kept');
top = null;
click(null);
assert.deepEqual(calls, [['clear']], 'open map lets it go');
state._trackedNorad = null;
click(dot);
assert.deepEqual(calls.at(-1), ['track', 25544]);
});