mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
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:
1 parent
7312280817
commit
bb3bf9858b
87 files changed
+1398
-1775
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import { isTrackingSelectionGesture } from '../../data/trackingClickGesture.js';
|
||||
import { findCamera, findFrame } from '../../render/rendererOf.js';
|
||||
import { loadFleetModelSet } from '../../data/fleetModels.js';
|
||||
import { forgetPlacedAircraft } from './placed.js';
|
||||
@@ -135,19 +134,6 @@ export function createLifecycle({
|
||||
registerPickOwner(
|
||||
'flights',
|
||||
(pickedId) => flightState._icons?.has(pickedId) === true,
|
||||
{
|
||||
expanded: true,
|
||||
// A click on the aircraft already tracked is ignored: for that one
|
||||
// plane the layer acts on nothing, so a card over it keeps the tap.
|
||||
passive: (pickedId) =>
|
||||
Boolean(flightState._trackedIcao) &&
|
||||
pickedId === flightState._trackedIcao,
|
||||
// The click handler ignores a dragged tap and any tap in cockpit
|
||||
// mode, so a card over the aircraft keeps that tap.
|
||||
declinesClick: (click) =>
|
||||
!isTrackingSelectionGesture(click?.gesture) ||
|
||||
Boolean(document.body?.classList.contains('cockpit-mode')),
|
||||
},
|
||||
);
|
||||
const frame = findFrame(viewer);
|
||||
if (!flightState._preRenderRemove && frame) {
|
||||
|
||||
@@ -4,6 +4,8 @@ import { createCivilFlightLayer } from './index.js';
|
||||
import { createFlightState } from './state.js';
|
||||
import { createEnrichment } from './enrichment.js';
|
||||
import { createTracking } from './tracking.js';
|
||||
import { fakeInput } from '../../input/testDoubles.mjs';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
import { LiveSourceError } from '../../sources/live/contract.js';
|
||||
|
||||
function services() {
|
||||
@@ -608,3 +610,47 @@ test('a route answer for a callsign the plane no longer flies is dropped', async
|
||||
assert.equal(meta.routeCallsign, 'UAL10');
|
||||
flightState.lifetime.abort();
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: an aircraft under another
|
||||
// layer's card is not even picked, so it is neither tracked nor released.
|
||||
test("another layer's card over an aircraft keeps the click", (t) => {
|
||||
const previousDocument = globalThis.document;
|
||||
globalThis.document = Object.assign(new EventTarget(), {
|
||||
body: { classList: { contains: () => false } },
|
||||
});
|
||||
let picks = 0;
|
||||
const viewer = {
|
||||
scene: {
|
||||
canvas: new EventTarget(),
|
||||
pick: () => {
|
||||
picks++;
|
||||
return null;
|
||||
},
|
||||
},
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
const flightState = createFlightState({ services: services() });
|
||||
flightState._trackedEntityChangedRemove = () => {};
|
||||
const tracking = createTracking({
|
||||
flightState,
|
||||
services: { ...services(), picking },
|
||||
parts: {},
|
||||
layer: {},
|
||||
});
|
||||
tracking._installClickHandler(viewer);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
picking.setClickCardHitTest(() => top);
|
||||
t.after(() => {
|
||||
picking.setClickCardHitTest(null);
|
||||
flightState._clickSubscription?.();
|
||||
input.destroy();
|
||||
flightState.lifetime.abort();
|
||||
if (previousDocument === undefined) delete globalThis.document;
|
||||
else globalThis.document = previousDocument;
|
||||
});
|
||||
input.tap({ x: 10, y: 10 });
|
||||
assert.equal(picks, 0, 'covered: the scene under the card is not picked');
|
||||
top = null;
|
||||
input.tap({ x: 10, y: 10 });
|
||||
assert.ok(picks > 0, 'open map: the click reaches the scene');
|
||||
});
|
||||
@@ -86,7 +86,8 @@ export function createTracking({
|
||||
const { trackedLabelModelFromText, refreshTrackedReadout } = services.readout;
|
||||
const { FOLLOW_MIN_RANGE_M, SELECTION_FOLLOW_TRANSITION_S, followViewFrom } =
|
||||
services.camera;
|
||||
const { resolvePickId, isOwnedByOtherLayer } = services.picking;
|
||||
const { resolvePickId, isOwnedByOtherLayer, isUnderOtherCard } =
|
||||
services.picking;
|
||||
const flightsLayer = layer;
|
||||
/** The tracked contact's billboard (an icon set on the draw port). */
|
||||
const trackedIcon = createTrackedAircraftIcon({
|
||||
@@ -1272,6 +1273,9 @@ export function createTracking({
|
||||
// first-person reference. A globe click must not fall through to the
|
||||
// normal empty-space deselection path; cockpit has explicit exit controls.
|
||||
if (document.body.classList.contains('cockpit-mode')) return;
|
||||
// Another layer's card or label painted on top takes the click: the item
|
||||
// under it does not act, and the click is not empty space either.
|
||||
if (isUnderOtherCard?.(event)) return;
|
||||
const picked = event.hit;
|
||||
|
||||
if (picked) {
|
||||
|
||||
Reference in new issue
Block a user