Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion frontend/src/css/ExplorePage.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ html[data-theme="dark"] .pill.active { background: var(--accent); color: var(--b
align-self: center;
margin-top: 12px;
margin-bottom: 12px;
z-index: 100;
}
.explore-search.closer {
margin-top: 12px;
Expand All @@ -97,6 +98,8 @@ html[data-theme="dark"] .pill.active { background: var(--accent); color: var(--b
border-radius: var(--radius);
padding: 10px 12px;
box-shadow: var(--shadow-1);
position: relative;
z-index: 1;
}
.search-input-wrap input {
flex: 1;
Expand All @@ -113,7 +116,7 @@ html[data-theme="dark"] .pill.active { background: var(--accent); color: var(--b
top: calc(100% + 4px);
left: 0;
right: 0;
z-index: 20;
z-index: 101;
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: var(--radius);
Expand Down
13 changes: 11 additions & 2 deletions frontend/src/pages/ExplorePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,20 @@ export default function ExplorePage() {
const suggestions = useMemo(() => {
const q = (query || "").trim().toLowerCase();
if (!q) return [];
return locations

// hashmaps are o(1) lookup to track unique locations
const seen = new Map();
locations
.map((r) => r.trip_location)
.filter(Boolean)
.filter((loc) => loc.toLowerCase().includes(q))
.slice(0, 8);
.forEach((loc) => {
const key = loc.toLowerCase().trim();
if (!seen.has(key)) {
seen.set(key, loc);
}
});
return Array.from(seen.values()).slice(0, 8);
}, [locations, query]);

// click-outside to close suggestions
Expand Down