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
Undo doesn't handle mass undos, history gets partially lost #60
Comments
Couldn't reproduce the issue with the SB demo at https://reaflow.dev/?path=/story/demos-undo-redo--simple Might be related to the shared store I'm using? (Recoil) |
I tried throttling the undo/redo, but it didn't yield good results. I couldn't locate the root of the issue. I feel like applying too many undos too fast corrupts the history or something similar. I created an online demo: Add 2 nodes by dragging the ports, then use undo/redo through cmd+z and while the undos will work, it won't be possible to redo them when using the shortcuts. Using the undo/redo buttons works fine though. |
I tried removing most of my business logic (custom nodes, recoil) and use something as basic as possible and the issue still persists. https://poc-nextjs-reaflow-mzxz3a5h0.vercel.app/ Added a "Add node" button (top right). When keeping cmd+z pressed after adding nodes, the "redo" action cannot be done. Doing undos one by one works correctly though (as before). I also noticed when the issue happens, and it happens even when clicking manually. Video: https://youtu.be/4llZSog66O0 👉 At this point, I believe the issue is from reaflow undo/redo implementation. When "undoing" from the "initial state", it looses the whole history. |
Okay, I think I've found the root cause. It's because I automatically add a "start" node if there is no "start" node. And when I do the last "undo", it removes the "start" node, which in turn recreates the start nodes, which counts as a new action and removes the "redo" history. |
Okay, so that was one of the reasons it didn't work properly. Fixed by Vadorequest/rwa-faunadb-reaflow-nextjs-magic@7dd9256 But now, I'm back at square one, when I first noticed the issue with undo/redo, which only allows partial redo when undoing too much at once using the cmd+z shortcut. (the above issue I just fixed was added in the meantime and wasn't why I opened this issue in the first place) |
@amcdnl After much time spent on this, I'm still unsure of the root issue. It seems to work fine in the demo, but doesn't on my app. I'm thinking about adding a few options to the useUndoRedo built-in utility, such as:
Does that make sense to you? |
Can you make a PR for the disable? You should be able to get the refs. |
I'll make a PR to allow disabling default shortcuts binding then. The reaflow/src/helpers/useUndo.ts Lines 200 to 209 in 0c15d99
|
I'm submitting a...
[x] Bug report
Current behavior
When using undo/redo, when using the cmd+z shortcut, if we keep pressing on it then the history gets messed up somehow and we cannot do cmd+shift+z more than once/twice.
When doing cmd+z multiple time (not spamming) then it works as expected.
Expected behavior
It should work the same way whether spamming cmd+z or not.
Environment
reaflow 3.0.5
The text was updated successfully, but these errors were encountered: