Skip to content

Commit

Permalink
Use goBack instead of goTo, add extra slug check to avoid double goBa…
Browse files Browse the repository at this point in the history
…ck call
  • Loading branch information
ciampo committed Oct 8, 2024
1 parent 5910c7b commit 28ce403
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function FontSize() {

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

const [ fontSizes, setFontSizes ] = useGlobalSetting(
Expand All @@ -53,10 +53,10 @@ function FontSize() {

// Navigate to the font sizes list if the font size is not available.
useEffect( () => {
if ( ! fontSize ) {
goTo( '/typography/font-sizes/', { isBack: true } );
if ( !! slug && ! fontSize ) {
goBack();
}
}, [ fontSize, goTo ] );
}, [ slug, fontSize, goBack ] );

if ( ! origin || ! slug || ! fontSize ) {
return null;
Expand Down

0 comments on commit 28ce403

Please sign in to comment.