Skip to content

Commit

Permalink
Revert "Avoid errors when a fontSize preset is not available (WordPre…
Browse files Browse the repository at this point in the history
…ss#65791)"

This reverts commit 9bd9bd6.
  • Loading branch information
huubl authored Oct 2, 2024
1 parent be987c7 commit a65acc1
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ToggleControl,
} from '@wordpress/components';
import { moreVertical } from '@wordpress/icons';
import { useState, useEffect } from '@wordpress/element';
import { useState } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -36,6 +36,7 @@ function FontSize() {

const {
params: { origin, slug },
goBack,
goTo,
} = useNavigator();

Expand All @@ -53,10 +54,10 @@ function FontSize() {

// 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;
fontSize.fluid !== undefined ? !! fontSize.fluid : !! globalFluid;

// Whether custom fluid values are used.
const isCustomFluid = typeof fontSize?.fluid === 'object';
const isCustomFluid = typeof fontSize.fluid === 'object';

const handleNameChange = ( value ) => {
updateFontSize( 'name', value );
Expand Down Expand Up @@ -106,6 +107,9 @@ function FontSize() {
};

const handleRemoveFontSize = () => {
// Navigate to the font sizes list.
goBack();

const newFontSizes = sizes.filter( ( size ) => size.slug !== slug );
setFontSizes( {
...fontSizes,
Expand All @@ -121,18 +125,6 @@ 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 (
<>
<ConfirmDeleteFontSizeDialog
Expand Down

0 comments on commit a65acc1

Please sign in to comment.