fix(SW-2757): add AnimatePresence to rate card modals to avoid page freeze
This commit is contained in:
@@ -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>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user