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:
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user