Keep search results, only hide sidebar when closed

This commit is contained in:
2026-04-27 14:27:25 +01:00
parent a0b4a4b3f3
commit d2eb888dcf
9 changed files with 69 additions and 46 deletions

View File

@@ -1144,6 +1144,8 @@ export default class MapComponent extends Component {
this.mapUi.returnToSearch = true; this.mapUi.returnToSearch = true;
} }
this.mapUi.preventNextZoom = true; this.mapUi.preventNextZoom = true;
this.mapUi.selectPlace(place, { preventZoom: true });
this.mapUi.showSidebar();
this.router.transitionTo('place', place); this.router.transitionTo('place', place);
}; };

View File

@@ -96,6 +96,7 @@ export default class PlaceRoute extends Route {
if (model) { if (model) {
const options = { preventZoom: this.mapUi.preventNextZoom }; const options = { preventZoom: this.mapUi.preventNextZoom };
this.mapUi.selectPlace(model, options); this.mapUi.selectPlace(model, options);
this.mapUi.showSidebar();
this.mapUi.preventNextZoom = false; this.mapUi.preventNextZoom = false;
} }
// Stop the pulse animation if it was running (e.g. redirected from search) // Stop the pulse animation if it was running (e.g. redirected from search)

View File

@@ -22,6 +22,7 @@ export default class PlaceNewRoute extends Route {
this.mapUi.updateCreationCoordinates(model.lat, model.lon); this.mapUi.updateCreationCoordinates(model.lat, model.lon);
} }
this.mapUi.startCreating(); this.mapUi.startCreating();
this.mapUi.showSidebar();
} }
deactivate() { deactivate() {

View File

@@ -193,6 +193,7 @@ export default class SearchRoute extends Route {
// Ensure pulse is stopped if we reach here // Ensure pulse is stopped if we reach here
this.mapUi.stopSearch(); this.mapUi.stopSearch();
this.mapUi.setSearchResults(model); this.mapUi.setSearchResults(model);
this.mapUi.showSidebar();
// Store current search params to allow "Up" navigation from place details // Store current search params to allow "Up" navigation from place details
const { q, category, lat, lon } = this.paramsFor('search'); const { q, category, lat, lon } = this.paramsFor('search');

View File

@@ -17,6 +17,15 @@ export default class MapUiService extends Service {
@tracked searchResults = []; @tracked searchResults = [];
@tracked currentSearch = null; @tracked currentSearch = null;
@tracked loadingState = null; @tracked loadingState = null;
@tracked isSidebarVisible = false;
showSidebar() {
this.isSidebarVisible = true;
}
hideSidebar() {
this.isSidebarVisible = false;
}
selectPlace(place, options = {}) { selectPlace(place, options = {}) {
this.selectedPlace = place; this.selectedPlace = place;

View File

@@ -18,12 +18,13 @@ export default class ApplicationComponent extends Component {
@tracked isAppMenuOpen = false; @tracked isAppMenuOpen = false;
get isSidebarOpen() { 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. // This helps the map know if it should shift the center or adjust view.
return ( return (
this.router.currentRouteName === 'place' || this.mapUi.isSidebarVisible &&
(this.router.currentRouteName === 'place' ||
this.router.currentRouteName === 'place.new' || this.router.currentRouteName === 'place.new' ||
this.router.currentRouteName === 'search' this.router.currentRouteName === 'search')
); );
} }
@@ -48,13 +49,12 @@ export default class ApplicationComponent extends Component {
handleOutsideClick() { handleOutsideClick() {
if (this.isAppMenuOpen) { if (this.isAppMenuOpen) {
this.closeAppMenu(); this.closeAppMenu();
} else if (this.router.currentRouteName === 'search') { } else if (
this.router.transitionTo('index'); this.router.currentRouteName === 'search' ||
} else if (this.router.currentRouteName === 'place') { 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? this.mapUi.clearSelection();
// Simplest behavior: clear selection this.mapUi.hideSidebar();
this.router.transitionTo('index');
} }
} }

View File

@@ -79,6 +79,7 @@ export default class PlaceTemplate extends Component {
if (place === null) { if (place === null) {
// If we have an active search context, return to it (UP navigation) // If we have an active search context, return to it (UP navigation)
if (this.mapUi.returnToSearch && this.mapUi.currentSearch) { if (this.mapUi.returnToSearch && this.mapUi.currentSearch) {
this.mapUi.showSidebar();
this.router.transitionTo('search', { this.router.transitionTo('search', {
queryParams: this.mapUi.currentSearch, queryParams: this.mapUi.currentSearch,
}); });
@@ -88,17 +89,19 @@ export default class PlaceTemplate extends Component {
} }
} else { } else {
// If a place is selected (unlikely in this view, but possible if we add related links) // If a place is selected (unlikely in this view, but possible if we add related links)
this.mapUi.showSidebar();
this.router.transitionTo('place', place); this.router.transitionTo('place', place);
} }
} }
@action @action
close() { close() {
// Clear search results so we don't fall back to the list this.mapUi.clearSelection();
this.router.transitionTo('index'); this.mapUi.hideSidebar();
} }
<template> <template>
{{#if this.mapUi.isSidebarVisible}}
<PlacesSidebar <PlacesSidebar
@selectedPlace={{this.place}} @selectedPlace={{this.place}}
@onClose={{this.close}} @onClose={{this.close}}
@@ -106,5 +109,6 @@ export default class PlaceTemplate extends Component {
@onBookmarkChange={{this.refreshMap}} @onBookmarkChange={{this.refreshMap}}
@onUpdate={{this.handleUpdate}} @onUpdate={{this.handleUpdate}}
/> />
{{/if}}
</template> </template>
} }

View File

@@ -56,15 +56,16 @@ export default class PlaceNewTemplate extends Component {
} }
<template> <template>
{{#if this.mapUi.isSidebarVisible}}
<div class="sidebar"> <div class="sidebar">
<div class="sidebar-header"> <div class="sidebar-header">
<h2><Icon @name="plus-circle" @size={{20}} @color="#ea4335" /> <h2><Icon @name="plus-circle" @size={{20}} @color="#ea4335" />
New Place</h2> New Place</h2>
<button type="button" class="close-btn" {{on "click" this.close}}><Icon <button
@name="x" type="button"
@size={{20}} class="close-btn"
@color="#333" {{on "click" this.close}}
/></button> ><Icon @name="x" @size={{20}} @color="#333" /></button>
</div> </div>
<div class="sidebar-content"> <div class="sidebar-content">
@@ -79,5 +80,6 @@ export default class PlaceNewTemplate extends Component {
/> />
</div> </div>
</div> </div>
{{/if}}
</template> </template>
} }

View File

@@ -11,6 +11,7 @@ export default class SearchTemplate extends Component {
selectPlace(place) { selectPlace(place) {
if (place) { if (place) {
this.mapUi.returnToSearch = true; this.mapUi.returnToSearch = true;
this.mapUi.showSidebar();
// We don't need to manually set currentSearch here because // We don't need to manually set currentSearch here because
// it was already set in the route's setupController // it was already set in the route's setupController
this.router.transitionTo('place', place); this.router.transitionTo('place', place);
@@ -19,14 +20,16 @@ export default class SearchTemplate extends Component {
@action @action
close() { close() {
this.router.transitionTo('index'); this.mapUi.hideSidebar();
} }
<template> <template>
{{#if this.mapUi.isSidebarVisible}}
<PlacesSidebar <PlacesSidebar
@places={{@model}} @places={{@model}}
@onSelect={{this.selectPlace}} @onSelect={{this.selectPlace}}
@onClose={{this.close}} @onClose={{this.close}}
/> />
{{/if}}
</template> </template>
} }