Media & text block: Try to fix JavaScript warning#54965
Media & text block: Try to fix JavaScript warning#54965
Conversation
|
Flaky tests detected in b641bf4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6379337727
|
|
Size Change: +95 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
|
Good catch, @carolinan! I think this code has been around for a while, and nobody noticed an error. Alternatively, you can also cast the |
t-hamano
left a comment
There was a problem hiding this comment.
Thanks for the PR, @carolinan!
I prefer the approach of casting to boolean, mentioned in this comment. In other blocks, we often see examples of casting attributes that may be undefined to boolean.
|
Lets go with the smaller fix :) |
|
it will be faster to close this PR and add the fix in a new. I will not have to time today because I'm attending a contributor day :) |
What?
Adds
falseas the default value for the ImageFill block attribute in the Media & Text block.Closes #54963
Why?
The imageFill block attribute is a boolean but has no default value.
In WP 6.4 beta this caused a JavaScript warning in the block editor when the setting "Crop image to fill entire column" was enabled. See the issue linked above.
Testing Instructions
Create a new post or page.
Add a media & text block. Select or upload an image.
Enable the option "Crop image to fill entire column"
Confirm that there is no JavaScript warning about the value changing from undefined to a defined value, and that the crop setting continues to work.
Deactivate Gutenberg, add two media and text blocks, one with the crop option enabled, one without. Activate Gutenberg again and confirm that there are no block validation errors.