fix(wildlife): a tap selects only a sighting exactly under it again

A click read the scene's exact pick at the tap. Through the input
dispatcher it read the click's id, which on a touch screen comes from the
wider contact search: a tap near a sighting selected it, and one near
another layer's contact kept the selection. It reads the exact top hit
again, as the shipwrecks and Local ADS-B layers do.
This commit is contained in:
Sameh Khamis committed 2026-11-14 01:51:24 -08:00
1 parent cbc0c114eb
commit 4f24b9a062
3 files changed
+28 -5

No files matched your search

@@ -204,7 +204,9 @@ function harness(
clicks.callback = (click) => clicks.callback = (click) =>
fn({ fn({
screenPosition: click.position, screenPosition: click.position,
id: picked?.id ?? picked?.primitive?.id ?? null, topHit: picked
? { set: 'wildlife', id: picked.id ?? picked.primitive?.id }
: null,
}); });
return () => { return () => {
clicks.destroyed = true; clicks.destroyed = true;
+7 -1
View File
@@ -498,7 +498,13 @@ export function createSelection({ state, services, parts }) {
return; return;
} }
// A sighting icon's item id is its pick id, `wildlife:<stableId>`. // A sighting icon's item id is its pick id, `wildlife:<stableId>`.
const id = click.id; // Read from what is exactly under the click, as the scene's pick was:
// a touch's wider contact search would select a sighting the tap
// missed, or keep one open for a tap near another layer's contact.
const picked = click.topHit;
const id = picked
? (services.picking?.resolvePickId?.(picked) ?? picked.id ?? null)
: null;
if ( if (
typeof id === 'string' && typeof id === 'string' &&
id.startsWith('wildlife:') && id.startsWith('wildlife:') &&
@@ -99,9 +99,13 @@ function fixture(sighting = row, extraServices = {}) {
for (const id of ids) painted.add(id); for (const id of ids) painted.add(id);
selection.photoCardsChanged(); selection.photoCardsChanged();
}, },
click(id = `wildlife:${sighting.stableId}`) { click(id = `wildlife:${sighting.stableId}`, { touchId } = {}) {
// The input dispatcher hands the pick's registry-resolved id. // The exact top hit, and the id a touch's wider contact search finds.
click({ screenPosition: { x: 10, y: 20 }, id: id ?? undefined }); click({
screenPosition: { x: 10, y: 20 },
topHit: id ? { set: 'wildlife', id } : null,
id: touchId ?? id ?? undefined,
});
}, },
}; };
} }
@@ -300,6 +304,17 @@ test('empty clicks and layer removal release the selected row and its overlay',
assert.equal(f.entries.size, 0); assert.equal(f.entries.size, 0);
}); });
test('a tap selects only a sighting exactly under it, not one the touch search found near it', () => {
const f = fixture();
f.selection.install();
f.click(null, { touchId: `wildlife:${row.stableId}` });
assert.equal(f.state.selectedId, null);
f.click();
assert.ok(f.state.selectedId);
f.click(null, { touchId: 'other:aircraft' });
assert.equal(f.state.selectedId, null, 'a tap near another contact clears');
});
test('each sighting in context carries the point voice projects to find what is in view', () => { test('each sighting in context carries the point voice projects to find what is in view', () => {
const registered = []; const registered = [];
const f = fixture(row, { const f = fixture(row, {