From f38a546175a0a15b262803dd518e23a5e124f8a5 Mon Sep 17 00:00:00 2001 From: ramon Date: Wed, 2 Oct 2024 10:57:37 +1000 Subject: [PATCH 1/2] When navigating back from the font sizes panel, the origin and slug navigation params are not available so let's return early. Also, remove goTo call in the ScreenHeader onBack callback since back navigation is built into `Navigator.BackButton` --- .../src/components/global-styles/font-sizes/font-size.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 80b1ea55c405bc..a632000d13e208 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 @@ -37,7 +37,6 @@ function FontSize() { const { params: { origin, slug }, goBack, - goTo, } = useNavigator(); const [ fontSizes, setFontSizes ] = useGlobalSetting( @@ -46,6 +45,10 @@ function FontSize() { const [ globalFluid ] = useGlobalSetting( 'typography.fluid' ); + if ( ! origin || ! slug ) { + return; + } + // Get the font sizes from the origin, default to empty array. const sizes = fontSizes[ origin ] ?? []; @@ -151,7 +154,6 @@ function FontSize() { __( 'Manage the font size %s.' ), fontSize.name ) } - onBack={ () => goTo( '/typography/font-sizes/' ) } /> { origin === 'custom' && ( From c3b9a7fba0b435b8e1f79282a435a968237b650f Mon Sep 17 00:00:00 2001 From: ramon Date: Wed, 2 Oct 2024 11:05:12 +1000 Subject: [PATCH 2/2] Reinstate goTo --- .../src/components/global-styles/font-sizes/font-size.js | 2 ++ 1 file changed, 2 insertions(+) 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 a632000d13e208..1ce4c97b91d989 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 @@ -37,6 +37,7 @@ function FontSize() { const { params: { origin, slug }, goBack, + goTo, } = useNavigator(); const [ fontSizes, setFontSizes ] = useGlobalSetting( @@ -154,6 +155,7 @@ function FontSize() { __( 'Manage the font size %s.' ), fontSize.name ) } + onBack={ () => goTo( '/typography/font-sizes/' ) } /> { origin === 'custom' && (