From 161a1426e4c781beaf0440a79f42c73f7af49864 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Fri, 6 Feb 2026 14:33:54 +0700 Subject: [PATCH] Sync selection list with map view toggle --- app/composables/useCatalogSearch.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) 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 }) }