Merged in fix/SW-1513-enter-details-scroll-issue (pull request #1433)

feat:enterdetails - fixed scroll achoring issue #sw-1513

* feat:enterdetails - fixed scroll achoring issue #sw-1513


Approved-by: Niclas Edenvin
This commit is contained in:
Linus Flood
2025-02-27 09:49:18 +00:00
parent f885760608
commit 58b2957b81

View File

@@ -81,14 +81,26 @@ export default function SectionAccordion({
// finish, else the height calculations will not be correct and the scroll position
// will be off.
if (shouldBeOpen) {
setTimeout(() => {
const handleTransitionEnd = () => {
if (accordionRef.current) {
window.scrollTo({
top: accordionRef.current.offsetTop - stickyPosition.getTopOffset(),
behavior: "smooth",
})
}
}, 250)
accordionRef.current?.removeEventListener(
"transitionend",
handleTransitionEnd
)
}
if (accordionRef.current) {
accordionRef.current.addEventListener(
"transitionend",
handleTransitionEnd,
{ once: true }
)
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentRoomIndex, roomIndex, roomStatus.currentStep, setIsOpen, step])