Skip to content

Block editor: place the caret in the next block on forward delete from an empty block - #80709

Closed
ellatrix wants to merge 2 commits into
trunkfrom
fix/forward-delete-empty-block
Closed

ellatrix wants to merge 2 commits into
trunkfrom
fix/forward-delete-empty-block

Conversation

@ellatrix

Copy link
Copy Markdown
Member

What?

Fixes #64235. Pressing forward delete in an empty block removes it and places the caret at the start of the next block, so repeated presses keep deleting forward. Previously the caret jumped backward to the end of the previous block.

Why?

mergeBlocks removed the unmodified first block with select-previous semantics. That is the one branch where the removed block itself holds the selection (a forward merge from an empty block), so the selection fell back to the block before it, against the direction of the gesture.

How?

When the removed first block was the selected one, select the second block at its start instead. The backward merge paths are untouched: there the removed block does not hold the selection, and their behavior is already correct.

Testing Instructions

  1. Add a paragraph with text, two empty paragraphs, and another paragraph with text.
  2. Place the caret in the first empty paragraph and press forward delete (Fn+Backspace on macOS) twice.
  3. The empty paragraphs are removed one by one and the caret ends at the start of the last paragraph. Previously the first press moved the caret to the end of the first paragraph.

Covered by an e2e test in all three engines; it fails on trunk.

Use of AI Tools

Written with Claude Code, reviewed and tested by me.

ellatrix and others added 2 commits July 24, 2026 15:31
Merging forward from an empty block removed it selecting the previous
block, jumping the caret backward to its end. The first block of a
merge only holds the selection when merging forward, so removing it
must select the second block at its start, letting repeated presses
keep deleting forward.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GQNdFF1FUU9JXfNGZev2na
@ellatrix ellatrix added [Type] Bug An existing feature does not function as intended [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... labels Jul 24, 2026
@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Jul 24, 2026
@github-actions

Copy link
Copy Markdown

Size Change: +15 B (0%)

Total Size: 7.75 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 428 kB +15 B (0%)

compressed-size-action

@ellatrix ellatrix closed this Jul 24, 2026
@ellatrix
ellatrix deleted the fix/forward-delete-empty-block branch July 24, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Forward delete from empty block selects previous block

1 participant