Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Shadow/Font size preset panel crashes the editor #65765

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ 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;
Expand Down Expand Up @@ -121,18 +132,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
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export default function ShadowsEditPanel() {
const [ isRenameModalVisible, setIsRenameModalVisible ] = useState( false );
const [ shadowName, setShadowName ] = useState( selectedShadow.name );

if ( ! category || ! slug ) {
return null;
}

const onShadowChange = ( shadow ) => {
setSelectedShadow( { ...selectedShadow, shadow } );
const updatedShadows = shadows.map( ( s ) =>
Expand Down
Loading