Skip to content

fix(editor): patch y-tiptap crash when typing into a new heading - #4032

Merged
JammingBen merged 2 commits into
mainfrom
fix/editor-heading-position-tracking
Oct 27, 2026
Merged

JammingBen merged 2 commits into
mainfrom
fix/editor-heading-position-tracking

Conversation

@JammingBen

Copy link
Copy Markdown
Member

Description

Typing into a new, empty heading crashes the editor when collaboration is active. For example, typing # and then any letter throws Position tracking requires synchronized editor text, and the keystroke is lost.

This regressed with the tiptap bump in #3791, which brought in @tiptap/y-tiptap 3.0.10. That release added position tracking for structural edits. Our TableOfContents extension 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 appendTransaction of our own that hits this, and TableOfContents only 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

@JammingBen JammingBen self-assigned this Oct 27, 2026
@JammingBen
JammingBen requested a review from kulmann October 27, 2026 10:57
@JammingBen
JammingBen enabled auto-merge October 27, 2026 11:14
@JammingBen
JammingBen merged commit e9511c5 into main Oct 27, 2026
28 checks passed
@JammingBen
JammingBen deleted the fix/editor-heading-position-tracking branch October 27, 2026 11:26
@openclouders openclouders mentioned this pull request Oct 27, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants