From 65c990d0290e79a58cccebe2f1d73f7f056b6d69 Mon Sep 17 00:00:00 2001 From: Grant Kinney Date: Tue, 23 Jan 2024 12:06:06 -0600 Subject: [PATCH] Font Library: Prevent error when installing a system font twice --- .../global-styles/font-library-modal/context.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 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 c5933ca46ec7b..864d703f260b4 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 @@ -286,10 +286,15 @@ function FontLibraryProvider( { children } ) { // Use the sucessfully installed font faces // As well as any font faces that were already installed (those will be activated) - fontFamilyToInstall.fontFace = [ - ...sucessfullyInstalledFontFaces, - ...alreadyInstalledFontFaces, - ]; + if ( + sucessfullyInstalledFontFaces?.length > 0 || + alreadyInstalledFontFaces?.length > 0 + ) { + fontFamilyToInstall.fontFace = [ + ...sucessfullyInstalledFontFaces, + ...alreadyInstalledFontFaces, + ]; + } // Activate the font family (add the font family to the global styles). activateCustomFontFamilies( [ fontFamilyToInstall ] );