Skip to content

Commit

Permalink
Global styles: improve Navigator usage in typography panel (WordPress…
Browse files Browse the repository at this point in the history
…#65942)

* Global styles: remove trailing slack from font sizes screen path

* Remove unncessary goTo

* Use goBack instead of goTo, add extra slug check to avoid double goBack call

---

Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
3 people authored and karthick-murugan committed Nov 13, 2024
1 parent be48daa commit 774abb9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 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 Expand Up @@ -158,7 +158,6 @@ function FontSize() {
__( 'Manage the font size %s.' ),
fontSize.name
) }
onBack={ () => goTo( '/typography/font-sizes/' ) }
/>
{ origin === 'custom' && (
<FlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function FontSizes() {
</HStack>
<ItemGroup isBordered isSeparated>
<NavigationButtonAsItem
path="/typography/font-sizes/"
path="/typography/font-sizes"
aria-label={ __( 'Edit font size presets' ) }
>
<HStack direction="row">
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/global-styles/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function GlobalStylesUI() {
<ScreenTypography />
</GlobalStylesNavigationScreen>

<GlobalStylesNavigationScreen path="/typography/font-sizes/">
<GlobalStylesNavigationScreen path="/typography/font-sizes">
<FontSizes />
</GlobalStylesNavigationScreen>

Expand Down

0 comments on commit 774abb9

Please sign in to comment.