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

-1
View File
@@ -24,7 +24,6 @@ export function createSubmarineCableLayer({
parts,
source,
inputFor,
overlayHost,
picking,
mapStackEventTarget,
};
+5 -27
View File
@@ -1,40 +1,18 @@
import { toRadians } from '../../geo/vector.js';
import { cameraOf } from '../../render/rendererOf.js';
const CARD_BACKGROUND_ID = 'submarine-cables';
export function createInteraction({
state,
parts,
inputFor,
overlayHost,
picking,
}) {
export function createInteraction({ state, parts, inputFor, picking }) {
function beginInteraction(viewer) {
if (state._clickSubscription) return;
// Our cables 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?.(
CARD_BACKGROUND_ID,
(hit) => state._enabled && Boolean(resolvePickRecord(hit)?.reference),
);
const unsubscribe = inputFor(viewer).onClick((event) => {
state._clickSubscription = inputFor(viewer).onClick((event) => {
if (!state._enabled) return;
// Cable labels are not interactive, so any overlay entry hit here is
// another layer's card or label painted over the cable: its click.
if (
overlayHost?.hitTest?.(event.screenPosition?.x, event.screenPosition?.y)
)
return;
// Cable labels are not interactive, so any card or label painted on
// top is another layer's, painted over the cable: its click.
if (picking?.clickCard?.(event)) return;
const record = resolvePickRecord(event.drawHit);
if (!record?.reference) return;
flyToReference(viewer, record.reference);
});
state._clickSubscription = () => {
unsubscribe();
picking?.unregisterCardBackground?.(CARD_BACKGROUND_ID);
};
}
/**
@@ -25,6 +25,8 @@ function harness({ overlayTop = null } = {}) {
},
}),
overlayHost: { hitTest: () => top },
// The card on top at a click, as the registry answers from the host.
picking: { clickCard: () => top },
});
interaction.beginInteraction({});
return {
@@ -57,33 +59,3 @@ test('a card painted over a cable keeps its click; with none the cable reads the
'with no card on top, the cable reads its pick',
);
});
// So a card on top (a live CCTV card) may act over the cable instead.
test('while it takes clicks, a drawn cable registers as card background', () => {
const state = { _enabled: true, _clickSubscription: null };
const interaction = createInteraction({
state,
parts: {
rendering: {
pickInfo: (hit) =>
hit?.set === 'cables:1' ? { reference: { lon: 1, lat: 2 } } : null,
},
},
inputFor: () => ({ onClick: () => () => {} }),
overlayHost: { hitTest: () => null },
picking,
});
interaction.beginInteraction({});
const cable = { set: 'cables:1', id: 'cable:0' };
try {
assert.equal(picking.isCardBackground(cable), true);
assert.equal(picking.isCardBackground({ set: 'other:1', id: 'x' }), false);
state._enabled = false;
assert.equal(picking.isCardBackground(cable), false);
state._enabled = true;
state._clickSubscription();
assert.equal(picking.isCardBackground(cable), false);
} finally {
state._clickSubscription?.();
}
});