-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Block API: Add attribute role-based filtering to 'isUnmodifiedBlock' #70764
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
Size Change: +8 B (0%) Total Size: 1.89 MB
ℹ️ View Unchanged
|
Here's a patch for testing #70741 fix. diff --git packages/block-editor/src/store/actions.js packages/block-editor/src/store/actions.js
index 4f0ad81e312..57d0c7a8f6f 100644
--- packages/block-editor/src/store/actions.js
+++ packages/block-editor/src/store/actions.js
@@ -1254,7 +1254,14 @@ export const mergeBlocks =
}
if ( ! blockAType.merge ) {
- dispatch.selectBlock( blockA.clientId );
+ if ( isUnmodifiedBlock( blockB, 'content' ) ) {
+ dispatch.removeBlock(
+ clientIdB,
+ select.isBlockSelected( clientIdB )
+ );
+ } else {
+ dispatch.selectBlock( blockA.clientId );
+ }
return;
} ScreencastCleanShot.2025-07-17.at.19.09.44.mp4 |
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach seems to me to be the best. It allows us to accurately detect blocks that are "semantically" unmodified.
Thanks for the feedback, @t-hamano! |
…ordPress#70764) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
What?
Related #70741 (comment).
PR introduces a new optional
role
parameter to theisUnmodifiedBlock
andisUnmodifiedDefaultBlock
functions, allowing for more granular checks of block attributes based on their roles.Why?
Currently, the block is considered unmodified when all of its attributes are equal to the defaults. While this is a reasonable assumption, there are instances when the block editor must determine whether the block's actual content has been changed.
See: #70741 (comment).
Testing Instructions
PR has unit test coverage.
Testing Instructions for Keyboard
Same.