diff --git a/app/components/map.gjs b/app/components/map.gjs index 5b0877b..fcf9995 100644 --- a/app/components/map.gjs +++ b/app/components/map.gjs @@ -1144,6 +1144,8 @@ export default class MapComponent extends Component { this.mapUi.returnToSearch = true; } this.mapUi.preventNextZoom = true; + this.mapUi.selectPlace(place, { preventZoom: true }); + this.mapUi.showSidebar(); this.router.transitionTo('place', place); }; diff --git a/app/routes/place.js b/app/routes/place.js index 5742974..d58563b 100644 --- a/app/routes/place.js +++ b/app/routes/place.js @@ -96,6 +96,7 @@ export default class PlaceRoute extends Route { if (model) { const options = { preventZoom: this.mapUi.preventNextZoom }; this.mapUi.selectPlace(model, options); + this.mapUi.showSidebar(); this.mapUi.preventNextZoom = false; } // Stop the pulse animation if it was running (e.g. redirected from search) diff --git a/app/routes/place/new.js b/app/routes/place/new.js index 33cfb6a..69727e6 100644 --- a/app/routes/place/new.js +++ b/app/routes/place/new.js @@ -22,6 +22,7 @@ export default class PlaceNewRoute extends Route { this.mapUi.updateCreationCoordinates(model.lat, model.lon); } this.mapUi.startCreating(); + this.mapUi.showSidebar(); } deactivate() { diff --git a/app/routes/search.js b/app/routes/search.js index e47eb08..1d9269c 100644 --- a/app/routes/search.js +++ b/app/routes/search.js @@ -193,6 +193,7 @@ export default class SearchRoute extends Route { // Ensure pulse is stopped if we reach here this.mapUi.stopSearch(); this.mapUi.setSearchResults(model); + this.mapUi.showSidebar(); // Store current search params to allow "Up" navigation from place details const { q, category, lat, lon } = this.paramsFor('search'); diff --git a/app/services/map-ui.js b/app/services/map-ui.js index 63e9603..b5a7823 100644 --- a/app/services/map-ui.js +++ b/app/services/map-ui.js @@ -17,6 +17,15 @@ export default class MapUiService extends Service { @tracked searchResults = []; @tracked currentSearch = null; @tracked loadingState = null; + @tracked isSidebarVisible = false; + + showSidebar() { + this.isSidebarVisible = true; + } + + hideSidebar() { + this.isSidebarVisible = false; + } selectPlace(place, options = {}) { this.selectedPlace = place; diff --git a/app/templates/application.gjs b/app/templates/application.gjs index 8dfd51b..091ae80 100644 --- a/app/templates/application.gjs +++ b/app/templates/application.gjs @@ -18,12 +18,13 @@ export default class ApplicationComponent extends Component { @tracked isAppMenuOpen = false; get isSidebarOpen() { - // We consider the sidebar "open" if we are in search or place routes. + // We consider the sidebar "open" if we are in search or place routes AND it's visible. // This helps the map know if it should shift the center or adjust view. return ( - this.router.currentRouteName === 'place' || - this.router.currentRouteName === 'place.new' || - this.router.currentRouteName === 'search' + this.mapUi.isSidebarVisible && + (this.router.currentRouteName === 'place' || + this.router.currentRouteName === 'place.new' || + this.router.currentRouteName === 'search') ); } @@ -48,13 +49,12 @@ export default class ApplicationComponent extends Component { handleOutsideClick() { if (this.isAppMenuOpen) { this.closeAppMenu(); - } else if (this.router.currentRouteName === 'search') { - this.router.transitionTo('index'); - } else if (this.router.currentRouteName === 'place') { - // If in place route, decide if we want to go back to search or index - // For now, let's go to index or maybe back to search if search params exist? - // Simplest behavior: clear selection - this.router.transitionTo('index'); + } else if ( + this.router.currentRouteName === 'search' || + this.router.currentRouteName === 'place' + ) { + this.mapUi.clearSelection(); + this.mapUi.hideSidebar(); } } diff --git a/app/templates/place.gjs b/app/templates/place.gjs index b39c515..e2f20c6 100644 --- a/app/templates/place.gjs +++ b/app/templates/place.gjs @@ -79,6 +79,7 @@ export default class PlaceTemplate extends Component { if (place === null) { // If we have an active search context, return to it (UP navigation) if (this.mapUi.returnToSearch && this.mapUi.currentSearch) { + this.mapUi.showSidebar(); this.router.transitionTo('search', { queryParams: this.mapUi.currentSearch, }); @@ -88,23 +89,26 @@ export default class PlaceTemplate extends Component { } } else { // If a place is selected (unlikely in this view, but possible if we add related links) + this.mapUi.showSidebar(); this.router.transitionTo('place', place); } } @action close() { - // Clear search results so we don't fall back to the list - this.router.transitionTo('index'); + this.mapUi.clearSelection(); + this.mapUi.hideSidebar(); } } diff --git a/app/templates/place/new.gjs b/app/templates/place/new.gjs index 6dcbf8f..1993924 100644 --- a/app/templates/place/new.gjs +++ b/app/templates/place/new.gjs @@ -56,28 +56,30 @@ export default class PlaceNewTemplate extends Component { } } diff --git a/app/templates/search.gjs b/app/templates/search.gjs index 854f60a..26b52da 100644 --- a/app/templates/search.gjs +++ b/app/templates/search.gjs @@ -11,6 +11,7 @@ export default class SearchTemplate extends Component { selectPlace(place) { if (place) { this.mapUi.returnToSearch = true; + this.mapUi.showSidebar(); // We don't need to manually set currentSearch here because // it was already set in the route's setupController this.router.transitionTo('place', place); @@ -19,14 +20,16 @@ export default class SearchTemplate extends Component { @action close() { - this.router.transitionTo('index'); + this.mapUi.hideSidebar(); } }