From 67ebef4fa08d4001ebaaabb5a38f0b19bb541efa Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Tue, 1 Jul 2025 09:28:23 +0000 Subject: [PATCH] Merged in fix/SW-2905-select-rate-page-multi- (pull request #2465) fix: SW-2905 Fixed room auto close after filter changes * fix: SW-2905 Fixed room auto close after filter changes Approved-by: Linus Flood --- apps/scandic-web/stores/select-rate/index.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/scandic-web/stores/select-rate/index.ts b/apps/scandic-web/stores/select-rate/index.ts index 38f4a7d92..f65e8ce29 100644 --- a/apps/scandic-web/stores/select-rate/index.ts +++ b/apps/scandic-web/stores/select-rate/index.ts @@ -31,10 +31,15 @@ export function createRatesStore({ initialActiveRoom, vat, }: InitialState) { - function updateUrl(booking: RatesState["booking"]) { + function updateUrl(booking: RatesState["booking"], activeRoom: number = -1) { const searchParams = serializeBookingSearchParams(booking, { initialSearchParams: new URLSearchParams(window.location.search), }) + if (activeRoom >= 0) { + searchParams.set("modifyRateIndex", activeRoom.toString()) + } else { + searchParams.delete("modifyRateIndex") + } window.history.replaceState({}, "", `${pathname}?${searchParams}`) } @@ -111,7 +116,7 @@ export function createRatesStore({ } let activeRoom = rateSummary.length - if (initialActiveRoom) { + if (initialActiveRoom !== undefined && initialActiveRoom >= 0) { activeRoom = initialActiveRoom } else if (rateSummary.length === booking.rooms.length) { // Finds the first unselected room and sets that to active @@ -274,7 +279,7 @@ export function createRatesStore({ state.booking.rooms[idx].packages = null } - updateUrl(state.booking) + updateUrl(state.booking, state.activeRoom) }) ) }, @@ -293,7 +298,7 @@ export function createRatesStore({ } state.booking.rooms[idx].packages = null - updateUrl(state.booking) + updateUrl(state.booking, state.activeRoom) }) ) }, @@ -433,7 +438,7 @@ export function createRatesStore({ state.booking.rooms[idx].packages = null } - updateUrl(state.booking) + updateUrl(state.booking, state.activeRoom) }) ) },