Don't start nearby search when unfocusing search by clicking map

This commit is contained in:
2026-02-20 19:14:39 +04:00
parent 00454c8fab
commit 43b2700465
7 changed files with 95 additions and 18 deletions

View File

@@ -33,6 +33,7 @@ export default class MapComponent extends Component {
selectedPinElement;
crosshairElement;
crosshairOverlay;
ignoreNextMapClick = false;
setupMap = modifier((element) => {
if (this.mapInstance) return;
@@ -169,6 +170,18 @@ export default class MapComponent extends Component {
});
this.mapInstance.addOverlay(this.locationOverlay);
// Track search box focus state on pointer down to handle race conditions
// The blur event fires before click, so we need to capture state here
element.addEventListener(
'pointerdown',
() => {
if (this.mapUi.searchBoxHasFocus) {
this.ignoreNextMapClick = true;
}
},
true
);
// Geolocation Setup
const geolocation = new Geolocation({
trackingOptions: {
@@ -711,6 +724,11 @@ export default class MapComponent extends Component {
};
handleMapClick = async (event) => {
if (this.ignoreNextMapClick) {
this.ignoreNextMapClick = false;
return;
}
// Check if user clicked on a rendered feature (POI or Bookmark) FIRST
const features = this.mapInstance.getFeaturesAtPixel(event.pixel, {
hitTolerance: 10,