mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42: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
@@ -1,6 +1,7 @@
|
||||
import { nextTick } from 'vue';
|
||||
import { isPointerFree } from '../data/inputOwnership.js';
|
||||
import { inputFor } from '../input/dispatcher.js';
|
||||
import { isUnderOtherCard } from '../data/pickRegistry.js';
|
||||
import { createInteractionSession } from '../director/interactions/session.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { useSceneInteractionsStore } from '../ui/stores/sceneInteractions.js';
|
||||
@@ -119,6 +120,9 @@ export function createSceneInteractions(
|
||||
session.activate(items);
|
||||
unsubscribeClick = inputFor(viewer).onClick((event) => {
|
||||
if (panel?.owner !== owner || !shown() || !available()) 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;
|
||||
// A pack feature is its draw set's item (see dataPacks/presentation.js).
|
||||
const hit = event.drawHit;
|
||||
if (!hit) return;
|
||||
|
||||
@@ -10,6 +10,8 @@ import { createPinia } from 'pinia';
|
||||
import { useSceneInteractionsStore } from '../ui/stores/sceneInteractions.js';
|
||||
import SceneInteractions from '../ui/views/panels/SceneInteractions.vue';
|
||||
import { createSceneInteractions } from './interactions.js';
|
||||
import { fakeInput } from '../input/testDoubles.mjs';
|
||||
import { setClickCardHitTest } from '../data/pickRegistry.js';
|
||||
|
||||
const target = (featureId) => ({ packId: 'qa', featureId });
|
||||
const key = (featureId) => JSON.stringify(['qa', featureId]);
|
||||
@@ -192,3 +194,39 @@ test("an earlier owner leaves a later owner's panel alone", async (t) => {
|
||||
await settle();
|
||||
assert.equal(later.getState().selected, 'fly');
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: a pack feature under
|
||||
// another layer's card is not selected for its actions.
|
||||
test("another layer's card over a pack feature keeps the click", async (t) => {
|
||||
document.body.replaceChildren();
|
||||
const container = document.body.appendChild(document.createElement('div'));
|
||||
const canvas = container.appendChild(document.createElement('canvas'));
|
||||
const pinia = createPinia();
|
||||
const app = createApp(SceneInteractions).use(pinia);
|
||||
app.mount(document.body.appendChild(document.createElement('div')));
|
||||
let picked = null;
|
||||
const viewer = { container, scene: { canvas, pick: () => picked } };
|
||||
const input = fakeInput(viewer);
|
||||
const store = useSceneInteractionsStore(pinia);
|
||||
const interactions = createSceneInteractions(viewer, {
|
||||
execute: async () => true,
|
||||
store,
|
||||
});
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
t.after(() => {
|
||||
setClickCardHitTest(null);
|
||||
interactions.destroy();
|
||||
input.destroy();
|
||||
app.unmount();
|
||||
});
|
||||
const feature = { set: 'qa:points', id: 'point' };
|
||||
interactions.activate(SHOT, new Map([[key('point'), feature]]));
|
||||
await nextTick();
|
||||
picked = { id: feature, primitive: {} };
|
||||
input.tap({ x: 10, y: 10 });
|
||||
assert.deepEqual(store.panel?.outlined ?? [], [], 'covered: not selected');
|
||||
top = null;
|
||||
input.tap({ x: 10, y: 10 });
|
||||
assert.deepEqual(store.panel.outlined, ['card', 'fly']);
|
||||
});
|
||||
Reference in new issue
Block a user