diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/context.js b/packages/edit-site/src/components/global-styles/font-library-modal/context.js index abfb5484e44bf..4d01c1326cbee 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/context.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/context.js @@ -93,7 +93,7 @@ function FontLibraryProvider( { children } ) { * * @param {Array} fonts - The font families that will be saved to the database. */ - const saveFontFamilies = async ( fonts ) => { + const saveFontFamilies = async ( fonts, shouldAutoSave = false ) => { // Gets the global styles database post content. const updatedGlobalStyles = globalStyles.record; @@ -104,8 +104,14 @@ function FontLibraryProvider( { children } ) { fonts ); - // Saves a new version of the global styles in the database. - await saveEntityRecord( 'root', 'globalStyles', updatedGlobalStyles ); + if ( shouldAutoSave ) { + // Saves a new version of the global styles in the database. + await saveEntityRecord( + 'root', + 'globalStyles', + updatedGlobalStyles + ); + } }; // Library Fonts @@ -309,8 +315,7 @@ function FontLibraryProvider( { children } ) { fontFamiliesToActivate ); // Save the global styles to the database. - await saveFontFamilies( activeFonts ); - + await saveFontFamilies( activeFonts, true ); refreshLibrary(); } @@ -343,7 +348,7 @@ function FontLibraryProvider( { children } ) { fontFamilyToUninstall ); // Save the global styles to the database. - await saveFontFamilies( activeFonts ); + await saveFontFamilies( activeFonts, true ); } // Refresh the library (the library font families from database).