From 2d791557b78187522da326b712d9e0d2f8418130 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Mon, 12 Aug 2024 16:40:06 +0200 Subject: [PATCH] fix(SW-203): only activate scrolling upon hiding rooms --- components/ContentType/HotelPage/Rooms/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/ContentType/HotelPage/Rooms/index.tsx b/components/ContentType/HotelPage/Rooms/index.tsx index 665de3de0..cda5f2d3a 100644 --- a/components/ContentType/HotelPage/Rooms/index.tsx +++ b/components/ContentType/HotelPage/Rooms/index.tsx @@ -41,8 +41,9 @@ export function Rooms({ rooms }: RoomsProps) { .sort((a, b) => a.sortOrder - b.sortOrder) function handleToggleShowMore() { - setAllRoomsVisible(!allRoomsVisible) - if (scrollRef.current) { + const newState = !allRoomsVisible + setAllRoomsVisible(newState) + if (scrollRef.current && !newState) { scrollRef.current.scrollIntoView({ behavior: "smooth" }) } } @@ -74,6 +75,7 @@ export function Rooms({ rooms }: RoomsProps) {