Skip to content
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

Incorrect cursor position after undo #38

Open
philippkuehn opened this issue Feb 16, 2021 · 5 comments
Open

Incorrect cursor position after undo #38

philippkuehn opened this issue Feb 16, 2021 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@philippkuehn
Copy link

philippkuehn commented Feb 16, 2021

Describe the bug
As soon as I create multiple nodes one after the other and want to undo this, the cursor stays in the last line. This issue can be reproduced on the official demo page.

To Reproduce
Steps to reproduce the behavior:

  1. create paragraph
  2. press enter
  3. press cmd+z/ctrl+z

Expected behavior
Cursor should be in the first line instead of the second.

Screenshots
https://user-images.githubusercontent.com/2500670/108116413-ce668880-709b-11eb-89ea-dff5a41d6c47.mp4

@philippkuehn philippkuehn added the bug Something isn't working label Feb 16, 2021
@philippkuehn
Copy link
Author

@dmonad ping 👀

@bedryck
Copy link

bedryck commented Mar 22, 2022

collab
Hey, I have the same bug. Any updates?

@hamflx
Copy link

hamflx commented Aug 2, 2022

The following is my solution, mainly to change three places:

  1. placing ystate within the undoManager event.
  2. place the memory cursor position within _prosemirrorChanged (too many plug-ins are executed so that oldState does not really represent the last cursor position).
  3. change the stack-item-popped event to stack-item-pop (I added this event myself, so you'll need to modify Yjs as well).

hamflx@e44952e

hamflx/yjs@716aa57

@Jordan-Ellis
Copy link

Any update on if there will be an official fix?

@romansp
Copy link

romansp commented Oct 18, 2023

@hamflx thanks for the provided details and patches. After combining them all together with the patch from #43 (comment) I got it working flawlessly. It also restores different types of selections correctly.

By what it looks like all these patches together should resolve the following issues: #43, #101, #139.

@dmonad is it worth starting new PR to address them as it looks like #118 is stale?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants