diff --git a/app/composables/useCatalogSearch.ts b/app/composables/useCatalogSearch.ts index 0728323..6b2c55e 100644 --- a/app/composables/useCatalogSearch.ts +++ b/app/composables/useCatalogSearch.ts @@ -220,11 +220,17 @@ export function useCatalogSearch() { } const startSelect = (type: SelectMode) => { + if (!selectMode.value) { + lastViewMode.value = mapViewMode.value + } updateQuery({ select: type }) } const cancelSelect = () => { - updateQuery({ select: null }) + updateQuery({ + select: null, + view: lastViewMode.value === 'offers' ? null : lastViewMode.value + }) } const selectItem = (type: string, id: string, label: string) => { @@ -232,7 +238,8 @@ export function useCatalogSearch() { updateQuery({ [type]: id, select: null, // Exit selection mode - info: null // Exit info mode + info: null, // Exit info mode + view: lastViewMode.value === 'offers' ? null : lastViewMode.value }) } @@ -299,7 +306,18 @@ export function useCatalogSearch() { } return 'offers' // default }) + const lastViewMode = useState('catalog-last-view-mode', () => 'offers') const setMapViewMode = (mode: MapViewMode) => { + if (selectMode.value) { + const newSelectMode: SelectMode = mode === 'hubs' ? 'hub' + : mode === 'suppliers' ? 'supplier' + : 'product' + updateQuery({ + view: mode === 'offers' ? null : mode, + select: newSelectMode + }) + return + } updateQuery({ view: mode === 'offers' ? null : mode }) }