Repository navigation
Conversation
|
Closes #29112. |
gwwar
left a comment
There was a problem hiding this comment.
Thanks for taking this one on @lukecarbis ! I also see the behavior that @paaljoachim noted. The code here looks correct to add support, but it looks like we'll need a few additional changes to the Button block to make sure this works correctly with custom font sizing.
Let us know if you'd be comfortable diving further into that, or if folks should help!
So I 🔍 tested a bit and custom font sizes work with TT1 Blocks but do not on Twenty Twenty.
TT1Blocks.mp4
twentytwenty.mp4
Inspecting the serialized block code we do see the custom font sizes saved, however this is applied to the div wp-block-button instead of the link. This means that other CSS rules win vs our custom value.
As a general hook applying the custom font style to the topmost block makes sense, so we might need to 🤔 a bit on the best way to fix this.
|
@gwwar I'll take another shot at this next week once the public holidays are out of the way. I'll let you know if it's too tough for me. |
|
@gwwar @paaljoachim I've made a small change that resolves this problem. Ready for you to take another look. |
|
Closer! This works in the editor but we don't see that reflected on the published page in Twenty Twenty. We'll also want to make sure we add the new class here: gutenberg/packages/block-library/src/button/save.js Lines 48 to 50 in 564a6c0
|
|
@gwwar Thanks for your review… and your patience! I've added the custom class to the save state now. Do you think it would be better to separate this out into a custom function? Similar to the way we're doing it with |
gwwar
left a comment
There was a problem hiding this comment.
Nice, thanks @lukecarbis this works well! I verified that both the edit/publish view is updated.
Do you think it would be better to separate this out into a custom function?
What we have here is good for now!
I did spot one corner case with styling not applying to a Document -> Button. To see this visit /wp-admin/post-new.php?gutenberg-demo and try to update the font size on the "Help build Gutenberg" button.
It looks like we also don't respect Width Settings in this case, so I think it'd be okay to leave for a follow up fix. I can approve this one as is and merge, but let me know if you'd rather fix that case in this PR.
| Twenty Twenty + Document -> Button |
|---|
![]() |
|
@gwwar I'd be happy to take a look that bug – my guess is that the Document > Button doesn't have a wrapper around the button for some reason. But I agree, that's probably best addressed in a separate PR. Thanks for approving! |
Sounds great! Feel free to add me as a reviewer. |




Description
Adds support for font size and font family to the Button Block
How has this been tested?
In TT1 Blocks and Twenty Twenty-One
Screenshots
Types of changes
New feature (non-breaking change which adds functionality)
Checklist:
*.native.jsfiles for terms that need renaming or removal).