-
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: Fix attribute defaults #23777
Conversation
@ellatrix: This should go in 5.5 Beta 2. |
Size Change: +4 B (0%) Total Size: 1.14 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.
Looks good, I tested and confirmed it fixes the issue. Code change is small but clear.
Is it worth keeping the variation after this?
Prior to d26842b, the Search block's label and buttonText attributes defaulted to `__( 'Search' )`. This meant that adding a Search block to a post or page resulted in `<!-- wp:search /-->` being inserted into the HTML. In d26842b, the defaults were removed so that Search could use a block.json file. The default values were instead implemented using a default block variation. This, however, meant that Search blocks added prior to d26842b would render with a blank label and button. This fix is to default label and buttonText to `__( 'Search' )` in the render_callback. Care must be taken here to permit these attributes to be '' in which case the label and/or button are hidden.
ab0133f
to
9f451a1
Compare
I did wonder this. We could remove the variation but then would have to change the frontend to display |
* Search: Fix attribute defaults Prior to d26842b, the Search block's label and buttonText attributes defaulted to `__( 'Search' )`. This meant that adding a Search block to a post or page resulted in `<!-- wp:search /-->` being inserted into the HTML. In d26842b, the defaults were removed so that Search could use a block.json file. The default values were instead implemented using a default block variation. This, however, meant that Search blocks added prior to d26842b would render with a blank label and button. This fix is to default label and buttonText to `__( 'Search' )` in the render_callback. Care must be taken here to permit these attributes to be '' in which case the label and/or button are hidden. * Try to trick GitHub into re-running tests
Fixes https://core.trac.wordpress.org/ticket/50608.
Prior to #22422, the Search block's
label
andbuttonText
attributes defaulted to__( 'Search' )
. This meant that adding a Search block to a post or page resulted in<!-- wp:search /-->
being inserted into the HTML.In #22422, the defaults were removed so that Search could use a
block.json
file. The default values were instead implemented using a default block variation.This, however, meant that Search blocks added prior to #22422 would render with a blank label and button. This is the bug outlined in the ticket above.
This fix is to default label and buttonText to
__( 'Search' )
in the block'srender_callback
. Note that care must be taken here to permit these attributes to be''
which hides the label and/or button.To test:
<!-- wp:search /-->
into a post's markup.