diff --git a/src/components/Map/MapView.jsx b/src/components/Map/MapView.jsx index 883504d..7e75d97 100644 --- a/src/components/Map/MapView.jsx +++ b/src/components/Map/MapView.jsx @@ -234,8 +234,17 @@ export default function MapView({ essential: true }); - // Clear search query after navigation - setSearchQuery(""); + // If picking a post, filter by its title; otherwise clear search + if (item.type === 'post' && item.title) { + setSearchQuery(item.title); + } else { + setSearchQuery(""); + } + }; + + const handleSearch = (query) => { + console.log('[MapView] Search/filter by:', query); + setSearchQuery(query); }; const handleOpenCreate = () => { @@ -449,6 +458,7 @@ export default function MapView({ diff --git a/src/components/Search/SmartSearchBar.jsx b/src/components/Search/SmartSearchBar.jsx index 6b47423..43ad552 100644 --- a/src/components/Search/SmartSearchBar.jsx +++ b/src/components/Search/SmartSearchBar.jsx @@ -52,12 +52,14 @@ function IconWaves(props) { * Props: * - placeholder * - onPick(item, { zoom, reason }) // call when user selects suggestion + * - onSearch(query) // call when user presses Enter to filter/search * - onMySpot() // keep same function (center on user) * - onPlaceTourWire() // keep same function (place/tour/wire) */ export default function SmartSearchBar({ placeholder = "Search places, regions, posts…", onPick, + onSearch, onMySpot, onPlaceTourWire, }) { @@ -144,9 +146,14 @@ export default function SmartSearchBar({ e.preventDefault(); setActive((i) => Math.max(i - 1, 0)); } else if (e.key === "Enter") { + e.preventDefault(); if (items.length && active >= 0) { - e.preventDefault(); + // Pick the selected suggestion pick(items[active], "enter"); + } else if (q.trim()) { + // No item selected, trigger search/filter + setOpen(false); + onSearch && onSearch(q.trim()); } } else if (e.key === "Escape") { setOpen(false);