-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Search Block: Remove unused buttonBehavior
attribute
#53467
Conversation
Size Change: -97 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
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.
I'm not sure about this, but we are using this same pattern of attributes that never get changed within the block to allow extenders to override the behavior of a block when using them in a pattern.
For example the group block accepts an allowedBlocks attribute which can be set by a pattern to control which blocks can be inserted within.
So this change might be a breaking change for extenders that have provided a custom value in a pattern or when they wrap the block in a custom wrapper.
I don't know of any examples myself. But I just wanted to call it out here.
56684c6
to
0496be4
Compare
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.
Thank you @t-hamano — I've tested and verified that Button Only search blocks function the same before and after this change, in addition as all other styles of the block.
I also tested by manually adding the buttonBehavior
attribute to the search block. No block validation errors occurred after switching to this PR, so it doesn't appear a deprecation is needed either.
Approving because I agree we should remove the attribute since it is unused, I think it was added in an earlier iteration of this implementation before the block was refactored to use the Interactivity API.
I added the Needs Dev Note label because as I stated before this technically is a backward compatibility thing. So at least in the miscellaneous dev note something should be added |
Dev NoteNote: It would probably be good to include it as part of a miscellaneous dev note The Search block had an attribute called With this change, this attribute will no longer be referenced even if it has been added manually. |
@fabiankaegy, I have written a Dev Note, could you review it to see if it is sufficient? Please feel free to update. |
@t-hamano thanks for adding the dev note :) This works for me 👍 |
Fixes: #53435
What?
This PR removes the
buttonBehavior
attribute from the Search block. As a result, conditional expressions that are no longer needed have also been deleted.Why?
The
buttonBehavior
attribute has a default value of "expand-searchfield", but this attribute is never updated withsetAttibutes()
, so the value never changes.So removing this attribute should have no effect.
How?
block.json
.Edit
component'sgetBlockClassName()
function generates two class names,wp-block-search__button-only
andwp-block-search__button-behavior-expand
, whenhasOnlyButton
is true. In other words, the two class names have the same role, so the style for either class name can be merged with the style for the other class name. I removed thewp-block-search__button-behavior-expand
class and changed it to only depend on thewp-block-search__button-only
class.Testing Instructions