fix(SW-203): only activate scrolling upon hiding rooms

This commit is contained in:
Erik Tiekstra
2024-08-12 16:40:06 +02:00
parent dc38b5f71a
commit 2d791557b7

View File

@@ -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) {
<div className={styles.ctaContainer}>
<Button
onClick={handleToggleShowMore}
intent="text"
variant="icon"
className={`${styles.showMoreButton} ${allRoomsVisible ? styles.showLess : ""}`}
>