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

+24 -4
View File
@@ -5,7 +5,12 @@ import { fromDegrees } from '../../geo/ellipsoid.js';
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
import { NEWS_KEY_PROVIDERS, createNewsLayer } from './index.js';
import { findPickOwner } from '../../data/pickRegistry.js';
import {
findPickOwner,
registerPickOwner,
setClickCardHitTest,
unregisterPickOwner,
} from '../../data/pickRegistry.js';
// Registers the shared `gev-trail:` no-op owner, as the app does.
import '../../data/trailRenderer.js';
import { getSelectedEntityContext } from '../../data/contextStore.js';
@@ -141,11 +146,12 @@ function fixture(
for (const fn of [...clickHandlers])
fn({ screenPosition: { x: 10, y: 10 }, topHit });
};
// The card on top at a click, as the host answers the pick registry.
setClickCardHitTest((x, y) => hitTestOverlay(x, y));
const layer = createNewsLayer({
source,
overlayHost,
inputFor: () => input,
hitTestOverlay,
now,
matchMedia: () => ({ matches: reduced }),
getViewCentre: () => centre(),
@@ -162,6 +168,7 @@ function fixture(
layer.attachShellServices({ runNavigation: (navigate) => navigate() });
t.after(() => {
layer.destroy();
setClickCardHitTest(null);
unbind();
if (originalWindow === undefined) delete globalThis.window;
else globalThis.window = originalWindow;
@@ -1289,7 +1296,7 @@ test('a click on a marker selects its report, on a beacon chooses its hotspot, o
assert.equal(clickHandlers.size, 0);
});
test('a covered news card yields; the top news card acts over a flight trail', async (t) => {
test('a covered news card and pin yield; the top news card acts over a trail or a vessel', async (t) => {
let hits = [];
const { layer, items, entries, click, flights } = fixture(t, {
height: 500_000,
@@ -1322,10 +1329,14 @@ test('a covered news card yields; the top news card acts over a flight trail', a
assert.equal(layer.getRowControls().feed.selected.id, 'major');
assert.deepEqual(layer.getRowControls().feed.filters, before.filters);
assert.equal(flights.length, flightCount);
// A news pin under another layer's card is that card's click too.
layer.setParams({ clear: true });
click({ set: 'news:1:points', id: marker.id, surface: false });
assert.equal(layer.getRowControls().feed.selected, null, 'covered pin');
hits = [];
click({ set: 'news:1:points', id: marker.id, surface: false });
assert.equal(layer.getRowControls().feed.selected.id, 'major');
hits.shift();
hits = [{ sourceId: 'news', entry: card }];
click(null);
assert.equal(activations, 1, 'the unobscured news card acts once');
// A flight trail is registered so every layer reads a click on it as a
@@ -1338,6 +1349,15 @@ test('a covered news card yields; the top news card acts over a flight trail', a
surface: false,
});
assert.equal(activations, 2, 'the news card acts over a flight trail');
// Over a vessel (a layer that acts on its pick) the card on top acts too;
// the vessel layer stands aside under it, so one click does one thing.
registerPickOwner('test-vessels', (id) => id === '353136000');
try {
click({ set: 'vessels:1', id: '353136000', surface: false });
assert.equal(activations, 3, 'the news card acts over a vessel');
} finally {
unregisterPickOwner('test-vessels');
}
});
test('zoomed out, a hotspot is one beacon; off, nothing draws; destroyed, the sets go', async (t) => {