From 0aaaa7989615a4f9ad01b1964e9c73a13c004fee Mon Sep 17 00:00:00 2001 From: Huub <50170696+huubl@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:34:19 +0200 Subject: [PATCH] Revert "Fix: Shadow/Font size preset panel crashes the editor (#65765)" This reverts commit f162973ff5ac7c8ede0aac8001ac9b2e43470498. --- .../global-styles/font-sizes/font-size.js | 23 ++++++++++--------- .../global-styles/shadows-edit-panel.js | 4 ---- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/font-sizes/font-size.js b/packages/edit-site/src/components/global-styles/font-sizes/font-size.js index 63310203ef05b1..ef520a0163c037 100644 --- a/packages/edit-site/src/components/global-styles/font-sizes/font-size.js +++ b/packages/edit-site/src/components/global-styles/font-sizes/font-size.js @@ -51,17 +51,6 @@ function FontSize() { // Get the font size by slug. const fontSize = sizes.find( ( size ) => size.slug === slug ); - // Navigate to the font sizes list if the font size is not available. - useEffect( () => { - if ( ! fontSize ) { - goTo( '/typography/font-sizes/', { isBack: true } ); - } - }, [ fontSize, goTo ] ); - - if ( ! origin || ! slug || ! fontSize ) { - return null; - } - // Whether the font size is fluid. If not defined, use the global fluid value of the theme. const isFluid = fontSize?.fluid !== undefined ? !! fontSize.fluid : !! globalFluid; @@ -132,6 +121,18 @@ function FontSize() { setIsRenameDialogOpen( ! isRenameDialogOpen ); }; + // Navigate to the font sizes list if the font size is not available. + useEffect( () => { + if ( ! fontSize ) { + goTo( '/typography/font-sizes/', { isBack: true } ); + } + }, [ fontSize, goTo ] ); + + // Avoid rendering if the font size is not available. + if ( ! fontSize ) { + return null; + } + return ( <> { setSelectedShadow( { ...selectedShadow, shadow } ); const updatedShadows = shadows.map( ( s ) =>