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