From a85fbc492f00ed181925250517edf179ed1530eb Mon Sep 17 00:00:00 2001 From: Sarah Norris <1645628+mikachan@users.noreply.github.com> Date: Mon, 15 Jan 2024 09:22:15 +0000 Subject: [PATCH] Font Library Modal: Reset the selected font when installing a new font (#57817) * Reset the selected font when installing a new font * Use setLibraryFontSelected directly * Add finally block to installFonts * Move setLibraryFontSelected to success block * Set library selected font in installed-fonts useEffect --- .../components/global-styles/font-library-modal/context.js | 5 ++--- .../global-styles/font-library-modal/installed-fonts.js | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) 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 e0749845788d60..364742901bd5fe 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 @@ -213,14 +213,13 @@ function FontLibraryProvider( { children } ) { 'settings.typography.fontFamilies', ] ); refreshLibrary(); - setIsInstalling( false ); - return response; } catch ( error ) { - setIsInstalling( false ); return { errors: [ error ], }; + } finally { + setIsInstalling( false ); } } diff --git a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js index d493a2a297b18b..0a9e29892be47f 100644 --- a/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js +++ b/packages/edit-site/src/components/global-styles/font-library-modal/installed-fonts.js @@ -77,6 +77,7 @@ function InstalledFonts() { !! libraryFontSelected && libraryFontSelected?.source !== 'theme'; useEffect( () => { + handleSelectFont( libraryFontSelected ); refreshLibrary(); // eslint-disable-next-line react-hooks/exhaustive-deps }, [] );