Skip to content

Rich text: Backspace at the start of a paragraph with an active format crashes the editor (insertBefore NotFoundError) #87100

Open

Description

@dsas

Description

Pressing Backspace at the start of a paragraph while a format is active (for example, after pressing → to enter bold text at the start of the paragraph) merges the paragraph into the previous block on the canvas, while the block editor still has two separate blocks. Inserting a block next to it then crashes the editor.

The crash seen is:

NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.

I expect Backspace to merge the two blocks as it does when no format is active, without the canvas and the block list getting out of step.

Step-by-step reproduction instructions

  1. Create a post with these blocks: a Heading, a Paragraph that starts with bold text (e.g. "Key point: first paragraph text."), and at least one more Paragraph.
  2. Click into the bold-leading paragraph and press Home.
  3. Press → once. The caret doesn't move; it enters the bold format boundary.
  4. Press Backspace. On the canvas, the paragraph's text joins the end of the heading, but List View still shows the Paragraph as a separate block.
  5. Press End, then Enter.
  6. The editor crashes with "The editor has crashed".

Screenshots, screen recording, code snippet

Block markup to paste into the code editor:

<!-- wp:heading -->
<h2 class="wp-block-heading">Overview</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><strong>Key point:</strong> first paragraph text.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Second paragraph text.</p>
<!-- /wp:paragraph -->

Environment info

  • Gutenberg 24.3.1 and 24.4.2, tested in WordPress Playground with the latest WordPress and the default block theme.
  • Chrome (Chromium), desktop macOS.

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    on Nov 19, 2026
  2. dsas commented on Nov 19, 2026

    @dsas
    ContributorAuthor

    I confirmed the cause with local builds and a Playwright probe, in Chromium on macOS. It was introduced by #79105.

    Paragraph, Heading and List item support editableRoot, so while one of them is selected and has siblings, the whole canvas is a single editing host. A delete the editor doesn't cancel is performed by the browser, which merges the block's element into its neighbour. The store keeps both blocks, and the next block inserted before the removed element makes React call insertBefore on a node that has left the block list.

    The Backspace/Delete handler in packages/block-editor/src/components/rich-text/event-listeners/delete.ts only cancels the key and merges through the store when the caret is collapsed at the edge with no active formats, so Backspace with an active format falls through to the browser. Removing the hasActiveFormats condition fixes that case.

    Other deletes at a block's edge crash the same way, because they don't arrive as a Backspace or Delete keydown, e.g. Ctrl+H on macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions