Add default block style if missing#12519
Conversation
|
@youknowriad Would love to get your thoughts on this |
| return null; | ||
| } | ||
|
|
||
| if ( ! type.styles && ! find( styles, 'isDefault' ) ) { |
There was a problem hiding this comment.
Is this ! type.styles really necessary?
There was a problem hiding this comment.
This condition checks whether the block type originally contains styles, whereas styles contains all styles (original styles + ones added through registerBlockStyle).
The default style only needs to be added when the block type didn't already contain styles in the beginning.
So yeah, it's necessary :-)
There was a problem hiding this comment.
The default style only needs to be added when the block type didn't already contain styles in the beginning.
I'm not certain I understand why? Why can't we always add a default style anytime we're missing one?
There was a problem hiding this comment.
Right. Yeah I guess I did some wrong thinking there 🤔
youknowriad
left a comment
There was a problem hiding this comment.
Sounds reasonable to me. I'm temptatively adding it to 4.8.
|
some tests (unit or e2e) would be good :) |
|
Cool. I'll try to add some tests. Is https://wordpress.org/gutenberg/handbook/contributors/testing-overview/ still the best reference for that? |
|
yes, the tests docs seems good. Let me know if you need help figuring it out. |
|
@swissspidy you can ping me if you need any help with tests :) |
|
Let's follow up with tests separately. |
* Add default block style if missing * Add 'block style' context
* Add default block style if missing * Add 'block style' context
Description
This attempts to fix #11613 by adding a default block style if block styles were added to a block which doesn't have any by default.
How has this been tested?
Only manual testing so far. I could need some assistance if E2E tests or similar are needed.
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: