Never act on what lies under a mission label when it is clicked

A click on a Space Missions label reaches every click subscriber so they can
let go of their selection, but the layers that test their own painted cards
or pick the scene themselves still found what lay under the label: CCTV
turned that camera on, FIRMS and Vessels selected and flew to theirs, News
and Wildlife Sightings opened their item, Perimeters, Ghost Maps and
Shipwrecks opened the card's link, ALPR selected its reader, and Local ADS-B
drilled the scene itself and selected the aircraft. Each now skips its own
test on such a click, and Local ADS-B drills through the click, so the click
only releases selections, as a click on empty map or another layer's
contact does. Ordinary clicks behave as before.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-18 17:05:43 -08:00
1 parent 8675ead171
commit 5feac417d6
22 files changed
+453 -72

No files matched your search

+38 -1
View File
@@ -17,6 +17,7 @@ import { createLocalAdsbModels } from './models.js';
import { entityRecord, readEntityRecord } from '../../data/entityRecords.js';
import { resolvePickId } from '../../data/pickRegistry.js';
import { fromDegrees, toLonLatH } from '../../geo/ellipsoid.js';
import { inputFor } from '../../input/dispatcher.js';
import { fakeInput } from '../../input/testDoubles.mjs';
import { hexColor } from '../../render/color.js';
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
@@ -1174,7 +1175,8 @@ function iconPick(draw, id) {
return { primitive: {}, id: { set: layerSet(draw, ':markers').spec.id, id } };
}
/** A viewer with a canvas and scripted picks, plus the layer's click action. */
/** A viewer with a canvas and scripted picks, plus the layer's click action.
* A click drills through the viewer's `drillHits`. */
function clickHarness() {
const scene = {
canvas: {},
@@ -1182,6 +1184,8 @@ function clickHarness() {
pick() {
return scene.pickResult;
},
drillPick: () =>
(base.viewer.drillHits ?? []).map((hit) => ({ primitive: {}, id: hit })),
};
const base = fakeViewer({ scene });
return {
@@ -1265,6 +1269,39 @@ test('a click on a local aircraft under an unowned or trail pick still selects i
assert.equal(calls.selected.length, 2, 'the Flights contact is not taken');
});
test('a click a label painted over a local aircraft takes never selects the aircraft, and lets go of the selection', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const harness = clickHarness();
const { layer, calls, draw } = await enabledLayer(receiver, clock, null, {
viewer: harness.viewer,
});
t.after(() => layer.destroy());
receiver.set({ aircraft: [record()] });
await layer.update();
const label = { over: true };
inputFor(harness.viewer.viewer).onOverlayClick(() => label.over);
const model = {
set: layerSet(draw, ':models').spec.id,
id: 'local-adsb:abc123',
surface: false,
};
// The aircraft is under the label, both exactly and in the drill.
harness.scene.pickResult = iconPick(draw, 'local-adsb:abc123');
harness.viewer.viewer.drillHits = [model];
harness.click();
assert.deepEqual(calls.selected, [], 'the aircraft beneath is not taken');
// Off the label the same click selects it; on the label it lets go.
label.over = false;
harness.click();
assert.deepEqual(calls.selected, ['local-adsb:abc123']);
label.over = true;
harness.click();
assert.deepEqual(calls.selected, ['local-adsb:abc123']);
assert.equal(calls.cleared.length, 1, 'the selection is released');
});
test('a grounded aircraft changing type keeps its drawn model on its own belly offset until the new one is ready', () => {
const { draw, viewer, camera } = modelViewer();
const models = createLocalAdsbModels({