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,16 +161,20 @@ export default function Modal({
} }
> >
{trigger} {trigger}
<InnerModal <AnimatePresence>
onAnimationComplete={onAnimationComplete} {shouldRender && (
animation={animation} <InnerModal
setAnimation={setAnimation} onAnimationComplete={onAnimationComplete}
title={title} animation={animation}
subtitle={subtitle} setAnimation={setAnimation}
withActions={withActions} title={title}
> subtitle={subtitle}
{children} withActions={withActions}
</InnerModal> >
{children}
</InnerModal>
)}
</AnimatePresence>
</DialogTrigger> </DialogTrigger>
) )
} }