Skip to content

fix(editor): Prevent section Backspace from deleting sections with non-text content#3220

Draft
bukinoshita wants to merge 1 commit intocanaryfrom
fix/section-backspace-atom-blocks-e3e6
Draft

fix(editor): Prevent section Backspace from deleting sections with non-text content#3220
bukinoshita wants to merge 1 commit intocanaryfrom
fix/section-backspace-atom-blocks-e3e6

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary by cubic

Prevents Backspace from deleting sections that contain dividers, images, or other leaf/atom blocks. Addresses Linear BU-667.

  • Bug Fixes
    • Updated isSectionEmpty to return false if any child is a leaf node (isLeaf), including horizontalRule and atom nodes.
    • Moved isSectionEmpty to packages/editor/src/utils/is-section-empty.ts and wired it into the section extension.
    • Added unit tests for empty paragraphs, text, horizontalRule, atom nodes, and mixed content.

Written for commit 7e77dea. Summary will update on new commits.

…ontent

The isSectionEmpty heuristic only checked textContent and content.size,
which caused sections containing leaf/atom nodes (e.g. dividers, images)
to be misclassified as empty. Pressing Backspace would then delete the
entire section despite it having visible content.

The fix adds a check for leaf child nodes (isLeaf covers both atom nodes
and self-closing nodes like horizontalRule). If any child is a leaf node,
the section is not considered empty.

Extracts isSectionEmpty into its own utility file with unit tests.

Resolves BU-667

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

⚠️ No Changeset found

Latest commit: 7e77dea

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-email Ready Ready Preview, Comment Apr 9, 2026 5:34pm
react-email-demo Ready Ready Preview, Comment Apr 9, 2026 5:34pm
react-email-examples Ready Ready Preview, Comment Apr 9, 2026 5:34pm

Request Review

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants