Skip to content

Don't move cursor to the top on first undo #110

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bharatkashyap
Copy link
Contributor

@bharatkashyap bharatkashyap commented Dec 20, 2022

Motivation

Thanks for making and maintaining this library! We are using it for the demos on https://mui.com/. The first undo on a demo causes the cursor to reset back to the first position:

Motivation.mov

Test plan

Before:

Before.mov

After:

After.mov

Related to #38

if (record) {
// Apply the changes and update the offset
this._updateInput(record);
this._updateInput({ ...record, selectionStart, selectionEnd });
Copy link
Collaborator

@oliviertassinari oliviertassinari Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it could be good to keep the responsibility of _undoEdit to undo the history stack. Would it work with this logic inside _applyEdits? Otherwise, maybe simply to have before we call _undoEdit.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like applying the undo stack should not include to not corrupt the other state - so this is the right location to add the code.
_applyEdits would also record the new change (which is not wanted here).

@DanOnCall
Copy link

This a great editor. I am glad I found this PR 👍 Saved the day! The undo jump was problematic. But, with your fix I was able to fix this behavior on a fork. Thank you 🙏

I think it's worth merging or looking into a revision if possible. Thank you all for this editor option.

@ghost
Copy link

ghost commented Apr 29, 2024

I also think this should have been merged.

I've used this package 2 years ago (before this PR was even created) and I'm shocked this bug still exists.
We were looking for a simple editor for some JSON editing, but the fact that this bug still exists is discouraging.

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

Successfully merging this pull request may close these issues.

3 participants