From 797859ac809360aee22a47a8d8974dbf77ddecf4 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 23 Dec 2025 16:10:06 -0500 Subject: [PATCH] Feature: Add search filtering on Enter key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users can now: 1. Type a query and press Enter (without selecting a suggestion) to filter posts on the map 2. When picking a post suggestion, it navigates AND filters by that post's title 3. When picking a city/place, it navigates but clears the filter Changes: - SmartSearchBar: Added onSearch prop, triggers on Enter with no active item - MapView: Added handleSearch() to set searchQuery for filtering - Posts are automatically filtered by usePostsEngine's matchesSearch() 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/components/Map/MapView.jsx | 14 ++++++++++++-- src/components/Search/SmartSearchBar.jsx | 9 ++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) 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);