Skip to content
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

[CYS on Core] Ensure the size of fonts is not affected by the font family changes #44424

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ import { isEqual, noop } from 'lodash';

const { GlobalStylesContext } = unlock( blockEditorPrivateApis );

// Removes the typography settings from the styles when the user is changing
// to a new typography variation. Otherwise, some of the user's old
// typography settings will persist making new typography settings
// depend on old ones
const resetTypographySettings = ( variation, userStyles ) => {
if ( variation.settings.typography ) {
delete userStyles.typography;
for ( const elementKey in userStyles.elements ) {
if ( userStyles.elements[ elementKey ].typography ) {
delete userStyles.elements[ elementKey ].typography;
}
}
}

return userStyles;
};

export const VariationContainer = ( { variation, children } ) => {
const { base, user, setUserConfig } = useContext( GlobalStylesContext );
const context = useMemo( () => {
Expand Down Expand Up @@ -58,7 +75,7 @@ export const VariationContainer = ( { variation, children } ) => {
variation.settings
),
styles: mergeBaseAndUserConfigs(
user.styles,
resetTypographySettings( variation, user.styles ),
variation.styles
),
};
Expand Down
4 changes: 4 additions & 0 deletions plugins/woocommerce/changelog/44424-44259-fix-font-size
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

CYS - Ensure the size of fonts is not affected by a font family change.