fix(SW-2757): add AnimatePresence to rate card modals to avoid page freeze

This commit is contained in:
Arvid Norlin
2025-05-15 07:49:30 +02:00
parent 9aeb38bef4
commit 623495a176

View File

@@ -1,6 +1,6 @@
'use client'
import { motion } from 'framer-motion'
import { AnimatePresence, motion } from 'framer-motion'
import { type PropsWithChildren, useEffect, useState } from 'react'
import {
Dialog,
@@ -132,6 +132,8 @@ export default function Modal({
}
}, [isOpen])
const shouldRender = isOpen || animation !== AnimationStateEnum.unmounted
if (!trigger) {
return (
<InnerModal
@@ -159,16 +161,20 @@ export default function Modal({
}
>
{trigger}
<InnerModal
onAnimationComplete={onAnimationComplete}
animation={animation}
setAnimation={setAnimation}
title={title}
subtitle={subtitle}
withActions={withActions}
>
{children}
</InnerModal>
<AnimatePresence>
{shouldRender && (
<InnerModal
onAnimationComplete={onAnimationComplete}
animation={animation}
setAnimation={setAnimation}
title={title}
subtitle={subtitle}
withActions={withActions}
>
{children}
</InnerModal>
)}
</AnimatePresence>
</DialogTrigger>
)
}