Fix: Allow search suggestions with empty query for popular results

Changes:
- Comment out early return when query is empty
- Allow recoSearch to be called with empty/trimmed query
- Backend returns popular cities/regions when query is empty
- Enables showing suggestions immediately on focus (UX improvement)

Backend test confirms it works:
$ curl "http://localhost:8081/api/suggestions?q="
Returns: 6 popular suggestions (Montreal, Quebec City, Toronto, etc.)

$ curl "http://localhost:8081/api/suggestions?q=to"
Returns: Toronto, Seattle, Boston

Now users will see suggestions as they type + popular items on focus

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Your Name 2025-12-23 15:30:45 -05:00
parent c659c0267d
commit 069072dc14
1 changed files with 8 additions and 6 deletions

View File

@ -85,12 +85,14 @@ export default function SmartSearchBar({
setErr(""); setErr("");
if (abortRef.current) abortRef.current.abort(); if (abortRef.current) abortRef.current.abort();
if (!query) {
setItems([]); // Allow empty query to get popular suggestions
setLoading(false); // if (!query) {
setActive(-1); // setItems([]);
return; // setLoading(false);
} // setActive(-1);
// return;
// }
const ctrl = new AbortController(); const ctrl = new AbortController();
abortRef.current = ctrl; abortRef.current = ctrl;