-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid overriding custom settings on font library save #60438
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +114 B (0%) Total Size: 1.73 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach, let's get some extensive testing and try to land this today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a couple of small re-wording suggestions and a comment about the duplicated setNestedValue
function, but otherwise, this is testing really well for me. This also improves the readability of this part of the code, and I think it's a good workaround for #60343 👍
I'm happy to approve as I can see it fixes the issue in #60343, but it'd be great to get some more testing before merging.
packages/edit-site/src/components/global-styles/font-library-modal/context.js
Show resolved
Hide resolved
packages/edit-site/src/components/global-styles/font-library-modal/context.js
Outdated
Show resolved
Hide resolved
packages/edit-site/src/components/global-styles/font-library-modal/context.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Sarah Norris <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming this fixes the bug, following the replication steps in #60343.
However, there is still a way to introduce unintentional typography changes to the frontend of the site, without using the Site editor "Save" button:
- Install and activate at least two fonts (say "Acme" and "Zeyada")
- Set a block on the page to use the "Acme" font family
- Save the changes in the Site editor, and load the front-end to see your changes
- Back in the Site editor, select a theme variation
- Open the Font Library and activate only "Zeyada"
- Refresh the front-end of the site: you will see the "Acme" font disappears, even though you haven't saved any Site editor changes.
I'm approving this PR, as it definitely improves the overall situation, and I think we should land it, but it shows that
- If we continue to update Global Styles from within the Font Library, outside the normal Site editor save flow, these kinds of edges cases seem likely to keep popping up--I think we should revisit the font activation flow
- The automatic de-activation of fonts (which can be used in individual blocks) when switching themes/variations continues to be problematic.
Yes, this is known, style variations change the whole theme.json but again, there's nothing different here from a color preset reset while a color is being used elsewhere. It's not something specific to fonts and kind of unrelated with this PR. That said, I agree that ideally the save flow should be the same as the rest of global styles, we shouldn't save right away, and just rely on the global save button instead. But yeah maybe better addressed separately. |
Co-authored-by: matiasbenedetto <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: mikachan <[email protected]> Co-authored-by: creativecoder <[email protected]> Co-authored-by: desrosj <[email protected]> Co-authored-by: estelaris <[email protected]> Co-authored-by: YanCol <[email protected]>
Cherry-picked for release in #60577. |
* Font Library: Reset notices when navigating away from the collection (#59981) Co-authored-by: Mamaduka <[email protected]> Co-authored-by: mikachan <[email protected]> Co-authored-by: annezazu <[email protected]> Co-authored-by: madhusudhand <[email protected]> * Pattern Explorer: Pass 'rootClientId' to the pattern list (#60014) Co-authored-by: Mamaduka <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: dsas <[email protected]> * Fix lightbox UI disallow editing (#59890) * Check that lightbox can be edited before rendering lightbox UI * Refactor to reduce duplicate code * Fix and clarify component rendering logic Fix issue wherein lightbox popover was rendering erroneously when a link had been configured. * Reset lightbox attributes when removing link * Show lightbox UI if block-level override differs from default In some cases, such as when lightbox settings already exist for a block when global lightbox settings in theme.json change, we should allow users to see the lightbox UI and change the settings if they conflict with the global settings, even if the lightbox UI is disabled globally. This prevents a block from getting stuck with legacy lightbox settings and allows users to reset the block-level lightbox settings if need be in these edge cases. Note: We do not display the UI if the block-level settings exist and match the global settings, as the block will behave as expected in those circumstances and showing the UI in those circumstances would likely just be confusing. * Handle edge case of removing existing link when lightbox is fully enabled * Fix focus loss preventing end-to-end test from passing * Add link to PR in comment Co-authored-by: artemiomorales <[email protected]> Co-authored-by: michalczaplinski <[email protected]> Co-authored-by: justintadlock <[email protected]> Co-authored-by: annezazu <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: jeherve <[email protected]> * Only show inserter in document tools if DFM is off (#60426) Co-authored-by: draganescu <[email protected]> Co-authored-by: youknowriad <[email protected]> * only show inserter in document tools if DFM is off * remove useless CSS hiding the inserter in DFM whcih is not rendered anymore * Fix don't close overlay menu when focus leaves submenu (#60406) Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: c4rl0sbr4v0 <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: annezazu <[email protected]> * Fix experimental useHasRecursion deprecation (#60451) Unlinked contributors: albanyacademy. Co-authored-by: talldan <[email protected]> Co-authored-by: andrewserong <[email protected]> Co-authored-by: ramonjd <[email protected]> * Fix pattern block recursion handling (#60452) - Trigger recursion short circuit as early as possible before any other effects that can reason about inner blocks have run. - Use separate wrapper components to do this to satisfy the rule of hooks. Co-authored-by: talldan <[email protected]> Co-authored-by: ramonjd <[email protected]> Co-authored-by: andrewserong <[email protected]> * remove alpha from edit post header (#60431) * Update the query block to permit non-core interactive blocks (#60006) * updated the query block to permit non-core interactive blocks * updated logic to correctly check all blocks inside the query support interactivity * removed check for core blocks * updated variable names and modal message per feedback * renamed variable blockSupportsInteractivityBool to blockSupportsInteractivity Unlinked contributors: poof86. Co-authored-by: colinduwe <[email protected]> Co-authored-by: cbravobernal <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: sethrubenstein <[email protected]> Co-authored-by: colorful-tones <[email protected]> * Add context to 'Library' string (#60520) Co-authored-by: ocean90 <[email protected]> Co-authored-by: t-hamano <[email protected]> * DateTimePicker: Change day button size back from 32px to 28px (#59990) * DateTimePicker: Change day button size back from 32px to 28px * Update changelog Co-authored-by: t-hamano <[email protected]> Co-authored-by: mirka <[email protected]> Co-authored-by: annezazu <[email protected]> Co-authored-by: getdave <[email protected]> * Avoid overriding custom settings on font library save (#60438) Co-authored-by: matiasbenedetto <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: mikachan <[email protected]> Co-authored-by: creativecoder <[email protected]> Co-authored-by: desrosj <[email protected]> Co-authored-by: estelaris <[email protected]> Co-authored-by: YanCol <[email protected]> --------- Co-authored-by: George Mamadashvili <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: mikachan <[email protected]> Co-authored-by: annezazu <[email protected]> Co-authored-by: madhusudhand <[email protected]> Co-authored-by: t-hamano <[email protected]> Co-authored-by: dsas <[email protected]> Co-authored-by: Artemio Morales <[email protected]> Co-authored-by: artemiomorales <[email protected]> Co-authored-by: michalczaplinski <[email protected]> Co-authored-by: justintadlock <[email protected]> Co-authored-by: gziolo <[email protected]> Co-authored-by: jeherve <[email protected]> Co-authored-by: Andrei Draganescu <[email protected]> Co-authored-by: Fabian Kägy <[email protected]> Co-authored-by: fabiankaegy <[email protected]> Co-authored-by: c4rl0sbr4v0 <[email protected]> Co-authored-by: Daniel Richards <[email protected]> Co-authored-by: talldan <[email protected]> Co-authored-by: andrewserong <[email protected]> Co-authored-by: ramonjd <[email protected]> Co-authored-by: colinduwe <[email protected]> Co-authored-by: colinduwe <[email protected]> Co-authored-by: sethrubenstein <[email protected]> Co-authored-by: colorful-tones <[email protected]> Co-authored-by: Dominik Schilling <[email protected]> Co-authored-by: ocean90 <[email protected]> Co-authored-by: Aki Hamano <[email protected]> Co-authored-by: mirka <[email protected]> Co-authored-by: getdave <[email protected]> Co-authored-by: Matias Benedetto <[email protected]> Co-authored-by: matiasbenedetto <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: creativecoder <[email protected]> Co-authored-by: desrosj <[email protected]> Co-authored-by: estelaris <[email protected]> Co-authored-by: YanCol <[email protected]>
Co-authored-by: matiasbenedetto <[email protected]> Co-authored-by: youknowriad <[email protected]> Co-authored-by: mikachan <[email protected]> Co-authored-by: creativecoder <[email protected]> Co-authored-by: desrosj <[email protected]> Co-authored-by: estelaris <[email protected]> Co-authored-by: YanCol <[email protected]>
What?
Avoid overriding custom settings on font library save.
Alternative approach of #60390 to fix: #60343
Why?
Fixes: #60343
How?
Manipulate the global styles post content to add the new font families and persist to the database the global styles content with the font families updated.
Testing Instructions
Follow the steps from: #60343
Screenshots or screencast
2024-04-03.16-32-00.mp4