fix(bikeshare): a double-click follows the selected station again

The selected station's highlight was a point entity, which the default
renderer's double-click followed; deselecting removed it and ended the
follow. As a draw-port point it took no part in it. The station dots were
point primitives before, so they still take none.
This commit is contained in:
Sameh Khamis committed 2026-11-14 01:30:38 -08:00
1 parent 9c4c831ba2
commit 0dc3a1fb66
2 files changed
+96 -1

No files matched your search

+24 -1
View File
@@ -1,5 +1,6 @@
import { t } from '../../i18n/index.js';
import { inputFor } from '../../input/dispatcher.js';
import { followOnDoubleClick } from '../../data/stockFollow.js';
import {
BIKESHARE_SELECTED_OVERLAY_SOURCE_ID,
BIKESHARE_SELECTED_OVERLAY_SOURCE_OPTIONS,
@@ -101,6 +102,8 @@ export function createSelection({
if (record?.position)
layerState._stationSet?.upsert([parts.rendering.stationItem(record)]);
if (layerState._selectedSet?.size()) layerState._selectedSet.clear();
// Removing the highlight entity ended the default renderer's follow of it.
layerState._stockFollow?.stop();
layerState._overlayHost.clearSource(BIKESHARE_SELECTED_OVERLAY_SOURCE_ID);
}
@@ -142,7 +145,7 @@ export function createSelection({
function _installClickHandler(viewer) {
if (layerState._clickSubscription) return;
layerState._clickSubscription = inputFor(viewer).onClick((event) => {
const clickOff = inputFor(viewer).onClick((event) => {
const hit = event.drawHit;
if (hit) {
@@ -162,6 +165,26 @@ export function createSelection({
// Clicked anything else — deselect.
if (layerState._selectedKey) _clearSelection();
});
// A double-click follows the selected station's highlight, as the
// default renderer followed the point entity it was (the station dots
// were point primitives, which it never followed).
layerState._stockFollow = followOnDoubleClick({
viewer,
inputFor,
name: 'bikeshare',
enabled: () => layerState._enabled,
targetFor: (hit) => {
const key = layerState._selectedKey;
const position = layerState._stationRenderMap.get(key)?.position;
if (hit.set !== layerState._selectedSet?.id || !position) return null;
return { key, position: () => ({ ...position }) };
},
});
layerState._clickSubscription = () => {
clickOff?.();
layerState._stockFollow?.destroy();
layerState._stockFollow = null;
};
document.addEventListener('keydown', _onKeyDown);
}