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 -11
View File
@@ -277,13 +277,18 @@ export function createShipwrecksLayer({
if (!clicks) return;
_clickHandler = clicks.onClick((click) => {
if (pointer && !pointer.isPointerFree()) return;
const at = click.screenPosition;
const cardHit = overlayHost.hitTest?.(at?.x, at?.y);
if (
cardHit?.sourceId === SHIPWRECKS_OVERLAY_SOURCE_ID &&
cardHit.entryId === _selectedCardId
) {
if (_selectedLink) openExternal(_selectedLink);
// The card or label painted on top takes the click, read once per
// click so every layer agrees: ours opens its source whatever is drawn
// under it; another layer's is that layer's click, so the markers
// under it do not act and the selection stays.
const cardHit = picking.clickCard?.(click) ?? null;
if (cardHit) {
if (
cardHit.sourceId === SHIPWRECKS_OVERLAY_SOURCE_ID &&
cardHit.entryId === _selectedCardId &&
_selectedLink
)
openExternal(_selectedLink);
return;
}
// A marker's item id is its pick id, `shipwreck:<id>`. Read from what is
@@ -300,10 +305,6 @@ export function createShipwrecksLayer({
}
if (pickId && picking.isOwnedByOtherLayer(SHIPWRECKS_LAYER_ID, pickId))
return;
// A covered card must neither open its source nor clear the selection.
// A marker of ours under that card was already selected by the pick
// check before this one.
if (cardHit) return;
if (_selectedId) {
clearSelection();
render();
+7 -1
View File
@@ -47,6 +47,8 @@ function harness({ snapshots, now = () => 1, cardHit = () => null } = {}) {
const { draw } = bindFakeDraw(viewer);
const queue = [...(snapshots || [])];
const requests = [];
// The card on top at a click, as the host answers the pick registry.
picking.setClickCardHitTest((x, y) => cardHit(x, y));
const layer = createShipwrecksLayer({
source: {
getSnapshot({ signal }) {
@@ -394,7 +396,7 @@ test('the page deadline subtracts the newest available source age from the limit
assert.equal(snapshotDeadline({ sources: both }, 0), 7 * DAY, 'defaults');
});
test('a covered selected card yields while genuine wreck markers still select', async () => {
test('a covered selected card and covered markers yield; bare markers select', async () => {
let painted = [];
const h = harness({
snapshots: [
@@ -421,8 +423,12 @@ test('a covered selected card yields while genuine wreck markers still select',
click();
assert.deepEqual(h.opened, []);
assert.equal(h.lastCard()[0].id, first.id);
// A marker under another layer's card is that card's click too.
h.pick('b');
click();
assert.equal(h.lastCard()[0].id, first.id, 'a covered marker yields');
painted = [];
click();
assert.equal(h.lastCard()[0].id, 'shipwreck-card:b');
painted = [{ sourceId: 'shipwrecks', entryId: 'shipwreck-card:b' }];
h.pick(null);