{{ message }}
Repository navigation
fix(muya): cancel Backspace that turns a setext heading into a paragraph (#5035) - #5381
Merged
Merged
Conversation
1 task done
…aph (#5035) Backspace at the start of a setext heading replaced it with a paragraph but, unlike the ATX heading, paragraph and thematic break handlers, left the key's default action running. The browser then merged the new paragraph into the block above and removed its element, so the paragraph stayed in the block tree with a detached DOM node. With a bullet list above the heading, Enter, Enter at the end of the list threw "Failed to execute 'insertBefore' on 'Node'". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Jocs
force-pushed
the
fix/5035-cross-block-native-edit
branch
from
September 16, 2026 10:24
7b8ae48 to
9321fc5
Compare
This was referenced Sep 16, 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.

Summary
Backspace at the start of a setext heading turned the heading into a paragraph in the model, but let the browser's own Backspace run as well. The browser then merged the new paragraph's element into the block above and removed it, so the paragraph stayed in the block tree with a detached element. With a bullet list above the heading, pressing Enter twice at the end of the list threw
NotFoundError: Failed to execute 'insertBefore' on 'Node'fromScrollPage.insertBefore ← ScrollPage.insertAfter ← ParagraphContent._enterInListItem— the #5035 crash.This PR fixes that one trigger and closes #5035. The two other triggers found while investigating it have their own issues, which track the remaining work:
Steps to reproduce
Headingand press Backspace.Headingjumps onto the end oftwoon screen while the document keeps both (saved as- one/- twoHeading/ blank line /Heading), and the second Enter opens the "Unexpected renderer process error" dialog. The same happens with an===underline.Root cause
SetextHeadingContent.backspaceHandlerconverts the heading to a paragraph at offset 0 but never callsevent.preventDefault(). The ATX heading, paragraph and thematic break handlers all do. The browser's default Backspace then merges the new paragraph's element into the block above.Fix
Call
event.preventDefault()beforeconvertToParagraph, as the ATX heading handler does.Test plan
src/block/content/setextHeadingContent/__tests__/backspaceHandler.spec.ts: Backspace at offset 0 is default-prevented and yields a paragraph; Backspace mid-text still goes to the input handler. The first case fails with the source change reverted.e2e/tests/editing/setext-heading-backspace-5035.spec.ts(Chromium): click at the start of a setext heading below a bullet list, Backspace, then Enter twice at the end of the list. With the source change reverted it fails with detached blocks and theinsertBeforeNotFoundError; with it, it passes.pnpm -C packages/muya test(1786 tests),pnpm -C packages/muya lint:types, eslint on the changed files (the e2e spec with--no-ignore).Fixes #5035
🤖 Generated with Claude Code