Repository navigation
fix(text-editor): reveal the change after undo, redo and paste - #11138
Open
MichaelUray wants to merge 2 commits into
Open
MichaelUray wants to merge 2 commits into
MichaelUray wants to merge 2 commits into
Conversation
In collaborative documents undo/redo is handled by the Yjs undo manager. y-prosemirror restores the selection captured before the Yjs transaction (the selection-restoring 'stack-item-popped' event fires only after the document was updated), so the cursor stays where it was and a change made outside the viewport is never shown. The custom markdown and table paste handlers also dispatched their transactions without scrollIntoView, unlike the default ProseMirror paste. Wrap the collaboration undo/redo commands so that, after a successful undo/redo, the cursor moves to the changed range and it is scrolled into view (selection-only transaction, not added to history). Add scrollIntoView to the smart paste and table paste transactions. Add unit tests for the changed-range helper and the paste scroll. Fixes hcengineering#7814 Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
…ation extension Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
MichaelUray
force-pushed
the
fix/editor-scroll-on-undo-paste
branch
from
October 19, 2026 06:42
85bd0ab to
d4d7aa0
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7814
Problem and change
In collaborative documents undo/redo is handled by the Yjs undo manager. y-prosemirror restores the selection captured before the Yjs transaction (the selection-restoring 'stack-item-popped' event fires only after the document was updated), so the cursor stays where it was and a change made outside the viewport is never shown. The custom markdown and table paste handlers also dispatched their transactions without scrollIntoView, unlike the default ProseMirror paste.
Wrap the collaboration undo/redo commands so that, after a successful undo/redo, the cursor moves to the changed range and it is scrolled into view (selection-only transaction, not added to history). Add scrollIntoView to the smart paste and table paste transactions. Add unit tests for the changed-range helper and the paste scroll.
Tests
New unit tests
plugins/text-editor-resources/src/components/extension/__tests__/collaboration.test.tsand an extra assertion inshortcuts/__tests__/smartPaste.test.ts. Checked manually on a self-hosted instance: after typing at the end of a long document and scrolling to the top, Ctrl/Cmd+Z scrolls to the change, redo scrolls to the restored text, and pasting a long plain-text block keeps the end of the paste in view.