-
Notifications
You must be signed in to change notification settings - Fork 744
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
[BUG] AnimatePresence doesn't update with the latest state if the state changes fast. #2023
Comments
I'm getting the same issue on the latest version of framer motion Screen.Recording.2023-03-20.at.9.27.15.AM.movYou can see the _actual_ current index and caption below the framer animation. The moment I click faster than the animation takes, framer gets out of sync, despite a unique key being applied per the docs. |
This is also happening for me as well after upgrading from 10.3.4 to 10.4.0. Looks like it was introduced as a regression in 10.4.0. It's especially easy to reproduce in unit tests where click events happen very quickly. |
I'm actually seeing this in a site running on There's no reason that if the key is unique that nodes shouldn't be getting removed/added properly, regardless of how fast changes are happening. If that's not the case, that should be made clear in the docs 😬 |
I'm having the same issue switching between two components based on a state update: reproduction Works fine on |
I've got the exact same issue and found the regression version: → Works fine on |
I'm experiencing the same issue on Would rather not roll back to v9 because clipPath anims only work in more recent versions for me. Anyone got a clue what broke? Like others said above it doesn't make much sense if key is reliably changing. Anyway thanks for the sanity, confirmation. Not having any AnimatePresence problems on 9.0.2. |
Also experiencing the same issue on one of our projects where a modal stack state occasionally changes quite frequently and causes We're actually on version 6.5.1 (Stuck on React 17 😬) but I did a force-update to the latest version (10.12.4 at the time of writing) and the behaviour was the same. |
@mattgperry I think this is related to some tests in a PR you recently merged (#2119)... I'm still seeing this issue persist even on the latest release ( Rapid changes cause items to not enter/exit properly on subsequent changes. This is causing a real fuss in production, especially when you start doing scroll-related animations:
It's difficult to pinpoint what framer-motion is doing behind the scenes, but I can 100% confirm that the |
It does seem to be exclusively a problem with |
Also for those still experiencing this, here's a quick workaround that seems to work well: <AnimatePresence mode="popLayout" initial={false}>
// your unique motion component
</AnimatePresence> And then add a Rapid changes do not experience the same degradation described in this thread 😎 |
I also have this maddening problem! popLayout is not a viable solution as it seems to actually pop the component outside of its normal layout, thereby not obeying a parent's overflow:hidden setting |
Downgrading to 9.0.2 fixed the issue for me. Thanks @benjaminwaterlot! |
I can confirm this still happens in the latest version. We have an animated modal dialog based on |
Same issue on the latest version (10.12.16).
Switching the |
Same problem here. Last version working for me is |
|
10.12.22 still have bug. |
10.13.0 still has the issue |
This is a very important issue. However, I have no idea what efforts Framer is making to fix this bug. I would like to know the roadmap or plan to fix this bug. |
this bug is driving me crazy and comes up randomly in a not-always-reproducible fashion in production code where timing is a factor of client browser, backend job duration, react component states updating... My current solution is to just comment out all exit props from variants and motion elements, which is obviously not ideal and ruins 50% of the reason we use framer-motion in the first place. It's making me seriously consider migrating away from this library completely, as animating a component while exiting and letting an entering component (often times the final value of some task that you want to display to the user) take its place is a huge deal, and can not break in a random fashion in production code! :( |
@pofixifop If the migration target is decided, please share it. We would also like to consider our organization. |
@pofixifop @owjs3901 probably you can try to fix it with a PR instead of migrating your whole project to another library. Framer motion is an open source project and the maintainer relies on the help of the community to fix such problems. Please consider contributing to the project ✌️ |
Okay, let's try help fix this. Here is a minimal reproduction showing the issue: Trying out different version of There seems to be a refactor of the ExitAnimation component between these versions: Anyone able to dig deep into this? 😇 |
The problem might be in this method. Probably one of these early returns should be patched. I am at moment not able to work on it but hope that it might help anyone else debugging the issue. |
thanks for the attention guys 🥰 @hatsumatsu the minimal repro sandbox is great - very concise and clearly showcases the issue @mattgperry let's do this!! 💪 |
I was ready to workspace to fix issue. The I will Investigate why don't reduce this length. If there are any additional achievements, I will comment. |
Any update on this? |
+1 |
Curious if this doesn't affect paying framer users as well. Seems to affect such an important core functionality. |
Also noticed this bug. Using framer 10.16.4. Downgraded to 10.5.0 which partially solves the problem for me. I have a Nextjs project that has a paginated list on a page. When fetching data for the next page I display a loading state. When the data is returned, I hide the loading state and show the data in a list. I am using However, due to Nextjs caching, if I make a request that has already been made (e.g. went from page 1 to page 2, then back to page 1), the response is nearly immediate. Because this is so fast Framer doesn't seem to pick up the state change and the loading state hangs indefinitely. Downgrading to 10.5.0 at least eliminates the indefinite loading state issue, but there is still no animation when the response is too fast, resulting in a state change that is too fast. |
Is there a concrete reason this issue has gone unresolved for so long? Phrased differently, is there a compelling reason not to expect a fix for this issue? (Intended behavior, unintended but necessary outcome of more important logic that cannot be changed without causing more global issues, phasing out of FM maintenance to work on paid Framer products, etc...) FM hits the absolute sweet spot of intuitive API and powerful/performant anims. But this is increasingly feeling like a deal breaker - if same-page enter/exit transitions are employed with the 'wait' mode applied anyway. I understand this is open source and with this comes no expectations of fixes, speedy or otherwise. Writing mainly because I'd just really prefer sticking with FM as my main React anim library. |
Still having this issue on 10.16.4. Any workarounds? |
I tried version 10.5.0 but noticed a similar issue. |
I am having the same behavior with Remix and the Outlet component, when I stay on the same page but changes the key everythings works fine. But if I change a page (implies the Outlet component to render a new child) the exit animations will skip. I noticed that on version 10.16.4 something blocks the re-render and let the key unchanged (works fine in 9.0.2 but with the exit skip). |
10.12.22 have this problem too |
I had the same issue with Use |
I'm having the same issue 10.16.4 |
I can spot some issue as well with Having this example:
when switching between tabs kinda fast, content might get mixed and lets say i'm on Send tab, i can see Send and Receive content under the same tab any ideas |
@mattgperry Thanks so much for merging the PR! In 10.16.5 the issue is solved in my test case: https://codesandbox.io/s/framer-motion-animatepresence-bug-w4ycgz |
thanks @mattgperry 10.16.5 works for me too 🎉 |
10.16.5 fixed it. |
|
I'm having this problem using mode="wait". In my case it is used in an Accordion component. I tested some past cases previously but none with success, and removing the mode="wait" from the accordions when clicked quickly stops them from updating correctly and no longer closes. The error is not visible on the screen, but it appears when I'm building the project. Framer version used: 10.16.5
|
I don't think this is fixed on 10.16.5. If a page change with I don't know if this is a different issue though. I've had it for a while and I'm unable to make a sandbox example at this moment, maybe someone else who's having this issue could confirm. |
10.16.5 still not working, 10.12.2 is working |
Fixed for me! Literally just ran into this issue for like the fifth time in two years. Sick of workarounds, was considering going back to RTG for enter/exit. Checked this thread on a whim and woah! Great work, no more breaking for me on |
Still getting this with: 11.0.24 working fine as well for me on 9.0.2 Used that example: https://codesandbox.io/p/sandbox/framer-motion-accordion-qx958?file=%2Fpackage.json%3A9%2C6-9%2C22 with version 11.0.24, if you click multiple time on one element, the animation breaks |
There are a number of bugs with `framer-motion` that can result in sync issues with AnimatePresence and the conditionally rendered component. You can see this if you rapidly click an accordion, occasionally it gets out of sync and is closed when it should be open. This is a bigger problem with the viewer where the user may hold down the `z` key. It's trivial to get it to lock up. For now, just remove the animation entirely. Upstream issues for reference: framer/motion#2023 framer/motion#2618 framer/motion#2554
There are a number of bugs with `framer-motion` that can result in sync issues with AnimatePresence and the conditionally rendered component. You can see this if you rapidly click an accordion, occasionally it gets out of sync and is closed when it should be open. This is a bigger problem with the viewer where the user may hold down the `z` key. It's trivial to get it to lock up. For now, just remove the animation entirely. Upstream issues for reference: framer/motion#2023 framer/motion#2618 framer/motion#2554
Describe the bug
AnimatePresence
doesn't update with the latest state if the state changes fast.Provide a CodeSandbox reproduction of the bug
CodeSandbox
Steps to reproduce
If the
+1
button was clicked slowly, the animation will update with the state. While if the button was clicked swiftly, the animation stops updating with the state.Expected behavior
The animation should update with the state.
Video or screenshots
If applicable, add a video or screenshots to help explain the bug.
2023-03-16.23-03-50.mp4
Environment details
OS:
Edition Windows 11 Pro
Version 22H2
Installed on 11/10/2022
OS build 22621.1413
Experience Windows Feature Experience Pack 1000.22639.1000.0
Browser:
Chrome
Version 111.0.5563.65 (Official Build) (64-bit)
npm package versions:
The text was updated successfully, but these errors were encountered: