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

+14 -24
View File
@@ -11,7 +11,11 @@ import {
import { BHOTE_KOSHI_FLOOD_PATH } from './bhoteKoshiFloodPath.js';
import * as Cesium from 'cesium';
import { setLocale } from '../i18n/index.js';
import { registerPickOwner, unregisterPickOwner } from './pickRegistry.js';
import {
registerPickOwner,
setClickCardHitTest,
unregisterPickOwner,
} from './pickRegistry.js';
import { SceneDirector } from '../scenes/director.js';
import { createPlaybackClock } from '../director/clock.js';
import { createDefaultScenePacks } from '../scenes/packs/defaults.js';
@@ -1071,8 +1075,9 @@ test('a click on the locator callout runs its action', async () => {
};
},
}),
hitTest: () => top,
});
// The card on top at a click, as the host answers the pick registry.
setClickCardHitTest(() => top);
await layer.init(viewer);
await layer.enable(viewer);
const click = (extra = {}) =>
@@ -1103,34 +1108,19 @@ test('a click on the locator callout runs its action', async () => {
};
click({ gesture: { travelPx: 30, durationMs: 80 } });
assert.deepEqual(activated, ['trigger'], 'a drag does not open it');
// An aircraft under it is that layer's click, exact or a touch contact.
registerPickOwner('test-planes', (id) => id === 'plane:1', {
expanded: true,
});
// On top, it takes the click over an aircraft or a camera under it, exact
// or a touch contact: those layers stand aside under a card.
registerPickOwner('test-planes', (id) => id === 'plane:1');
try {
const plane = { set: 'planes:1', id: 'plane:1' };
const cam = { set: 'cams:1', id: 'cam:1' };
click({ topHit: plane, hit: plane });
click({ topHit: null, hit: plane });
assert.deepEqual(activated, ['trigger'], 'the aircraft takes it');
click({ topHit: cam, hit: cam });
assert.equal(activated.length, 4, 'the callout on top acts each time');
} finally {
unregisterPickOwner('test-planes');
}
// A layer that acts only on exact hits does not take a touch contact, and
// one that ignores this click (a long press on a camera) takes nothing: the
// callout keeps both.
registerPickOwner('test-cameras', (id) => id === 'cam:1', {
declinesClick: (event) => (event?.gesture?.durationMs ?? 0) > 400,
});
try {
const cam = { set: 'cams:1', id: 'cam:1' };
click({ topHit: null, hit: cam });
assert.equal(activated.length, 2, 'a near miss of an exact-only camera');
click({ topHit: cam, hit: cam, gesture: { travelPx: 0, durationMs: 900 } });
assert.equal(activated.length, 3, 'a long press the camera ignores');
click({ topHit: cam, hit: cam });
assert.equal(activated.length, 3, 'a clean click on the camera is its own');
} finally {
unregisterPickOwner('test-cameras');
setClickCardHitTest(null);
}
await layer.disable();
assert.equal(onClick, null, 'disable removes the click handler');