mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +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
@@ -28,7 +28,7 @@ import {
|
||||
createApplicationDirectionsLayer,
|
||||
} from './directions.js';
|
||||
import { GROUND_FLOOR_LIFT_M } from './groundFloor.js';
|
||||
import { isActedOnByOtherLayer, isOwnedByOtherLayer } from './pickRegistry.js';
|
||||
import { isOwnedByOtherLayer, setClickCardHitTest } from './pickRegistry.js';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import { instructionFor } from './routeSteps.js';
|
||||
import { setLocale } from '../i18n/index.js';
|
||||
@@ -467,10 +467,9 @@ function ownershipFixture(t) {
|
||||
});
|
||||
}
|
||||
|
||||
// Directions acts only on its maneuver steps. The route line and the A/B
|
||||
// markers are passive picks: still not empty space to other layers, but a
|
||||
// card painted over them (a quake card) keeps its click.
|
||||
test('enabled, directions owns its picks and acts only on its steps', (t) => {
|
||||
// Directions owns its route, markers and steps while enabled: none of them
|
||||
// is empty space to other layers.
|
||||
test('enabled, directions owns its picks', (t) => {
|
||||
ownershipFixture(t);
|
||||
const viewer = {
|
||||
scene: {
|
||||
@@ -488,24 +487,45 @@ test('enabled, directions owns its picks and acts only on its steps', (t) => {
|
||||
'directions:step:3',
|
||||
])
|
||||
assert.equal(isOwnedByOtherLayer('earthquakes', id), true, id);
|
||||
assert.equal(
|
||||
isActedOnByOtherLayer('earthquakes', 'directions:route'),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
isActedOnByOtherLayer('earthquakes', 'directions:marker:a'),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
isActedOnByOtherLayer('earthquakes', 'directions:step:3'),
|
||||
true,
|
||||
);
|
||||
} finally {
|
||||
directionsLayer.disable(viewer);
|
||||
}
|
||||
assert.equal(isOwnedByOtherLayer('earthquakes', 'directions:route'), false);
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: directions does not even
|
||||
// pick under another layer's card, so no step is selected or cleared there.
|
||||
test("another layer's card over directions keeps the click", (t) => {
|
||||
ownershipFixture(t);
|
||||
let picks = 0;
|
||||
const viewer = {
|
||||
scene: {
|
||||
pick: () => {
|
||||
picks++;
|
||||
return null;
|
||||
},
|
||||
canvas: { clientWidth: 100, clientHeight: 100 },
|
||||
},
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
t.after(() => {
|
||||
setClickCardHitTest(null);
|
||||
input.destroy();
|
||||
});
|
||||
directionsLayer.enable(viewer);
|
||||
try {
|
||||
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');
|
||||
} finally {
|
||||
directionsLayer.disable(viewer);
|
||||
}
|
||||
});
|
||||
|
||||
test('placing an endpoint takes the pointer, and every exit path gives it back', (t) => {
|
||||
ownershipFixture(t);
|
||||
|
||||
|
||||
Reference in new issue
Block a user