From 41e09f082abf5933d34613e8645b38cd51fb0139 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Mon, 19 May 2025 13:58:20 +0000 Subject: [PATCH] Merged in feat/SW-2800-lightbox-history-state (pull request #2147) feat(SW-2800): closing image gallery and lightbox on using browser navigation * feat(SW-2800): closing image gallery and lightbox on using browser navigation Approved-by: Linus Flood --- .../HotelReservation/SidePeek/index.tsx | 10 +++------- .../components/ImageGallery/index.tsx | 8 ++++---- .../Lightbox/Gallery/gallery.module.css | 4 ++++ apps/scandic-web/components/Lightbox/index.tsx | 16 +++++++++++++++- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/apps/scandic-web/components/HotelReservation/SidePeek/index.tsx b/apps/scandic-web/components/HotelReservation/SidePeek/index.tsx index 2b67bb627..5dd897473 100644 --- a/apps/scandic-web/components/HotelReservation/SidePeek/index.tsx +++ b/apps/scandic-web/components/HotelReservation/SidePeek/index.tsx @@ -37,10 +37,6 @@ export default function HotelReservationSidePeek() { room.roomTypes.some((type) => type.code === roomTypeCode) ) - function handleCloseClick() { - window.history.back() - } - useEffect(() => { if (activeSidePeek) { window.history.pushState(null, "", window.location.href) @@ -71,7 +67,7 @@ export default function HotelReservationSidePeek() { hotel={{ ...hotelData.hotel, url: hotelData.url }} restaurants={hotelData.restaurants} activeSidePeek={activeSidePeek} - close={handleCloseClick} + close={closeFn} showCTA={showCTA} /> )} @@ -87,7 +83,7 @@ export default function HotelReservationSidePeek() { )} diff --git a/apps/scandic-web/components/ImageGallery/index.tsx b/apps/scandic-web/components/ImageGallery/index.tsx index 93a0e3f0a..ec4ff029e 100644 --- a/apps/scandic-web/components/ImageGallery/index.tsx +++ b/apps/scandic-web/components/ImageGallery/index.tsx @@ -24,7 +24,7 @@ function ImageGallery({ hideLabel, }: ImageGalleryProps) { const intl = useIntl() - const [lightboxIsOpen, setLightboxIsOpen] = useState(false) + const [isOpen, setIsOpen] = useState(false) const [imageError, setImageError] = useState(false) const imageProps = fill ? { fill, sizes } : { height, width: height * 1.5 } @@ -52,7 +52,7 @@ function ImageGallery({