Font Family Picker: allow selecting the "Default" font for all text elements and blocks, which didn't work with some themes#44355
Open
mpkelly wants to merge 1 commit into
Conversation
…lements and blocks, which didn't work with some themes
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @mpkelly! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Quick Summary
This PR makes "Default" a valid font family choice for all themes and for all elements and blocks. What "Default" means depends on where you set it. The inheritance hierarchy looks like this:
Setting "Default" for H1-H6 means they will use the All Headings
font-family. If that is also set to "Default" it will use the Textfont-family. If Text is also set to "Default" then it will use the browser default which is normallyserife.g.Times.I don't think this hierarchy will be clear to all of Gutenberg's users and I have another PR which includes a hint. That Post Title doesn't update when you set the heading it is based on, e.g. H2, is something that caught me out during testing.
What?
fontFamilyat element or block-level, e.g. Pendant.TypographyPanelso it reflects the Editor & Sitefont-familyWhy?
font-familyto use the "X" font, but this didn't work on some themes like Pendant.How?
The "Default" font value was
''which is removed by the config merge logic and meant the base value was always used if it was present. This PR allows empty values to pass through and means the "Default" font style can be applied from a higher level.Note: there is a question about using this approach: was the use of
cleanEmptyObjectintended to stop unnecessary network traffic, or was it for some other reason? An empty value is valid and necessary according to my tests with various Global Style controls, but maybe I missed something. Please check this as part of the review.Testing Instructions
fontFamilyat the element level inthemes.json.TypographyPanelPreview, Editor and Site reflect the styles correctly. I tested with Blockbase, Pendant and Twenty Twenty-Two, plus several others.Screenshots or screencast
Example of the problem (from WordPress.com):
Screen.Capture.on.2565-09-22.at.16-10-48.mp4