Skip to content

Writing Flow: Remove empty blocks when the merge target doesn't support merging #70741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

megane9988
Copy link
Contributor

@megane9988 megane9988 commented Jul 16, 2025

What?

Closes #70739

When deleting a heading block with the backspace key below an image block, the heading block itself does not disappear.
I have taken care of the issue above.

Why?

To maintain consistency in operations

How?

  • packages/block-editor/src/store/actions.js

If the first block doesn't support merging and the second block is empty, remove the second block and focus on the first block.

Testing Instructions

  1. Add an image block (https://cldup.com/cXyG__fTLN.jpg)
  2. Add a heading block directly below
  3. Enter a suitable string into the heading block
  4. Delete the characters in the heading block using the backspace key
  5. After the last character disappears, the heading block remains empty, and the cursor moves to the image block

Screenshots or screencast

Before

2025-07-08.16.38.04.mov

After

2025-07-16.23.20.23.mov

Copilot AI and others added 8 commits July 8, 2025 07:46
Co-authored-by: megane9988 <1205958+megane9988@users.noreply.github.com>
…utes

Co-authored-by: megane9988 <1205958+megane9988@users.noreply.github.com>
…rations

Co-authored-by: megane9988 <1205958+megane9988@users.noreply.github.com>
Co-authored-by: megane9988 <1205958+megane9988@users.noreply.github.com>
@megane9988 megane9988 marked this pull request as ready for review July 16, 2025 14:24
@megane9988 megane9988 requested a review from ellatrix as a code owner July 16, 2025 14:24
Copy link

github-actions bot commented Jul 16, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @Copilot.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: Copilot.

Co-authored-by: megane9988 <megane9988@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... labels Jul 16, 2025
@Mamaduka
Copy link
Member

@megane9988, I just merged to #70764. After rebasing, you should be able to fix this with isUnmodifiedBlock. Here's the updated diff - #70764 (comment).

@megane9988
Copy link
Contributor Author

@Mamaduka
Thank you!! It works well!

@Mamaduka Mamaduka changed the title Feature/delete heading backspace does not remove #70739 Writing Flow: Remove empty blocks when the merge target doesn't support merging Jul 18, 2025
await expect( imageBlock ).toBeFocused();
} );

test( 'heading block with content should merge with paragraph above', async ( {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the file is named block-deletion, it doesn't seem appropriate to test block merging here. I think that a test equivalent to this one has already been done sufficiently in the splitting-merging.spec.js file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your review.
I will delete the second test.

megane9988 and others added 2 commits July 23, 2025 01:07
change the title according to the updated test.

Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

From what I've tested, everything seems fine 👍 I'll leave the final review to @Mamaduka.

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Looks good to me ✅ Thank you, @megane9988!

@megane9988
Copy link
Contributor Author

👍 @Mamaduka @t-hamano 👓
Thank you all too!

@Mamaduka Mamaduka merged commit bb8ee5e into WordPress:trunk Jul 23, 2025
101 of 105 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.4 milestone Jul 23, 2025
USERSATOSHI pushed a commit to USERSATOSHI/gutenberg that referenced this pull request Jul 23, 2025
…rt merging (WordPress#70741)

Co-authored-by: megane9988 <megane9988@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
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... [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When deleting a heading block with the backspace key below an image block, the heading block itself does not disappear.
4 participants