Skip to content

perf(ui): do not re-animate drawer on re-render, reduce useEffects #12743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 10, 2025

Conversation

AlessioGr
Copy link
Member

@AlessioGr AlessioGr commented Jun 10, 2025

Previously, every time the drawer re-rendered a new entry animation may be triggered. This PR fixes this by setting the open state to modalState[slug]?.isOpen instead of false.

Additionally, I was able to simplify this component while maintaining functionality. Got rid of one useEffect and one useState call. The remaining useEffect also runs less often (previously, it ran every time modalState changed => it re-ran if any modal opened or closed, not just the current one)

@AlessioGr AlessioGr enabled auto-merge (squash) June 10, 2025 17:57
@AlessioGr AlessioGr merged commit cb3f9bb into main Jun 10, 2025
77 checks passed
@AlessioGr AlessioGr deleted the perf/drawer branch June 10, 2025 21:14
elliott-w pushed a commit to elliott-w/payload that referenced this pull request Jun 12, 2025
…ayloadcms#12743)

Previously, every time the drawer re-rendered a new entry animation may
be triggered. This PR fixes this by setting the open state to
`modalState[slug]?.isOpen` instead of `false`.

Additionally, I was able to simplify this component while maintaining
functionality. Got rid of one `useEffect` and one `useState` call. The
remaining useEffect also runs less often (previously, it ran every time
`modalState` changed => it re-ran if _any_ modal opened or closed, not
just the current one)
Copy link
Contributor

🚀 This is included in version v3.43.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants