Repository navigation
fix(editor): patch y-tiptap crash when typing into a new heading - #4032
Merged
Merged
Conversation
kulmann
approved these changes
Oct 27, 2026
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.
Description
Typing into a new, empty heading crashes the editor when collaboration is active. For example, typing
#and then any letter throwsPosition tracking requires synchronized editor text, and the keystroke is lost.This regressed with the tiptap bump in #3791, which brought in
@tiptap/y-tiptap3.0.10. That release added position tracking for structural edits. OurTableOfContentsextension sets a heading id in an appended transaction once the heading gets its first character. y-tiptap then reads the Yjs document before the typed character has been written to it, finds that it doesn't match the editor, and throws. It's an upstream bug, and 3.0.10 is still the latest release.This PR adds a pnpm patch for
@tiptap/[email protected]. When an appended transaction follows an edit that hasn't been written to Yjs yet, the patch skips position tracking for it, so the edit syncs the way it did in 3.0.9.Trade-off: the guard also skips position tracking for an appended structural change that follows a remote edit, which worked before. We have no
appendTransactionof our own that hits this, andTableOfContentsonly changes attributes, so the impact is low. A tighter check is possible but would couple the patch more closely to y-tiptap's internals.The patch can be removed once upstream ships a fix.
Related Issue