From 871662bccf92c4da1b568783e4febdbefe3ce3cd Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 1 May 2026 18:51:39 +0000 Subject: [PATCH] fix(PlaceCard): correct boundary fetch for basemap label clicks When clicking city/area labels with wikidataId, the wikidata path now: 1. Always runs when wikidataId is present (removed OSM data guard) 2. Sets osm_type='R' and osm_id from wikidata's osm_relation_id 3. This allows Effect 3 (fetchPlaceDetails) to then fetch wiki_summary Also prevents Effect 2 (reverse geocode) from overwriting OSM data that was already set by the wikidata path. Fixes: boundary outline, fly-to-bounds, wiki summary display Co-Authored-By: Claude Opus 4.5 --- src/components/PlaceCard.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/PlaceCard.jsx b/src/components/PlaceCard.jsx index 40c4660..8fab953 100644 --- a/src/components/PlaceCard.jsx +++ b/src/components/PlaceCard.jsx @@ -359,6 +359,8 @@ export function PlaceCard({ place, variant = "preview", expanded = true, onToggl if (result?.raw?.osm_type && result?.raw?.osm_id) { const current = useStore.getState().selectedPlace if (current && current.lat === placeLat && current.lon === placeLon) { + // Skip if OSM data already set (e.g., by wikidata path with osm_relation_id) + if (current.raw?.osm_type && current.raw?.osm_id) return // Merge OSM data into raw, preserving existing data useStore.getState().setSelectedPlace({ ...current, @@ -393,7 +395,7 @@ export function PlaceCard({ place, variant = "preview", expanded = true, onToggl }, [osmType, osmId, placeLat, placeLon]) useEffect(() => { - if (osmType && osmId) return + // Always run wikidata path when wikidataId is present if (!wikidataId) return const controller = new AbortController() fetchPlaceByWikidata(wikidataId, controller.signal).then((data) => { @@ -405,6 +407,16 @@ export function PlaceCard({ place, variant = "preview", expanded = true, onToggl osm_relation_id: data.osm_relation_id, extratags: { ...(prev && prev !== "loading" ? prev.extratags : {}), ...data.extratags }, })) + // Set OSM data from wikidata response so Effect 3 can fetch wiki_summary + if (data.osm_relation_id) { + const current = useStore.getState().selectedPlace + if (current && current.lat === placeLat && current.lon === placeLon) { + useStore.getState().setSelectedPlace({ + ...current, + raw: { ...current.raw, osm_type: "R", osm_id: data.osm_relation_id } + }) + } + } if (data?.boundary) { const current = useStore.getState().selectedPlace if (current && current.lat === placeLat && current.lon === placeLon) { @@ -417,7 +429,7 @@ export function PlaceCard({ place, variant = "preview", expanded = true, onToggl } }) return () => controller.abort() - }, [wikidataId, osmType, osmId, placeLat, placeLon]) + }, [wikidataId, placeLat, placeLon]) useEffect(() => { if (variant !== "preview" || !userLocation || placeLat == null || placeLon == null) { setDriveTime(null); return }