From 3e23ec161c4ce4d65845ebc477599238148fecd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Tue, 30 Jun 2026 16:56:15 +0200 Subject: [PATCH] Only hide sidebar for new searches --- app/controllers/search.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/controllers/search.js b/app/controllers/search.js index 3cd7305..909f161 100644 --- a/app/controllers/search.js +++ b/app/controllers/search.js @@ -20,7 +20,24 @@ export default class SearchController extends Controller { category = null; fetchResultsTask = task({ restartable: true }, async (params) => { - // Hide sidebar and clear previous results immediately to signal a new search + // 1. Check if the incoming parameters match our currently loaded search + const isSameSearch = + this.mapUi.currentSearch && + params.q === this.mapUi.currentSearch.q && + params.category === this.mapUi.currentSearch.category && + params.lat === this.mapUi.currentSearch.lat && + params.lon === this.mapUi.currentSearch.lon; + + const hasResults = + this.mapUi.searchResults && this.mapUi.searchResults.length > 0; + + // 2. If it's a back navigation to the exact same search, resolve instantly with no animation + if (isSameSearch && hasResults) { + this.mapUi.showSidebar(); + return; + } + + // 3. Otherwise, this is a brand new search: hide the sidebar and clear previous results immediately to signal a new search this.mapUi.hideSidebar(); this.mapUi.clearSearchResults();