Fix overwriting existing line height style when none has been set in CoBlocks #1526
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The latest version of Gutenberg includes typography settings which already exist in CoBlocks. This PR doesn't fully harmonise those settings, but it stops CoBlock from disabling the core settings.
Using
line-height
as an example: if the line height was unset in CoBlocks, thenapplyStyle()
would set the inline style tonull
. This means that if core Gutenberg had set it's own line height then it would get nulled out. As shown in #1500 this caused the line height to be removed on the front end and could cause invalid block errors.This PR only sets an inline typography style if one has been set in CoBlocks, otherwise it leaves it alone. This means the CoBlocks setting takes precedent over the core Gutenberg setting on the front end. Maybe it should be the other way round, but this at least fixes the invalid block errors.
It's possible to do this without the
_.pickBy
function but it's more verbose and I saw this function was already used elsewhere in the plugin. From a code size point of view.Fixes #1500
Types of changes
Bug fix (non-breaking change which fixes an issue)
How has this been tested?
And checked the other way round just to be sure
Also tried the above using the other blocks that have custom typograph settings.
Checklist: