Skip to content

Commit

Permalink
Remove hasGlobalStyleVariations condition to show the Styles menu ite…
Browse files Browse the repository at this point in the history
…m in the edit site sidebar. Also, move its uid prop to MainSidebarNavigationContent for consistency and convenience. Why? When a block theme lacks global style variations, the top-level Styles panel in the Site Editor does not open on mobile. The sidebar navigation styles item now contains the global styles UI and no longer just the variations so the `hasGlobalStyleVariations` causes the bug and is, also, redundant.
  • Loading branch information
ramonjd committed Dec 4, 2024
1 parent ee87766 commit 98a482b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { useSelect, useDispatch } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import { useDispatch } from '@wordpress/data';
import { useCallback } from '@wordpress/element';
import { store as preferencesStore } from '@wordpress/preferences';
import { privateApis as routerPrivateApis } from '@wordpress/router';
Expand All @@ -23,26 +22,15 @@ const { useLocation, useHistory } = unlock( routerPrivateApis );

export function SidebarNavigationItemGlobalStyles( props ) {
const { params } = useLocation();
const hasGlobalStyleVariations = useSelect(
( select ) =>
!! select(
coreStore
).__experimentalGetCurrentThemeGlobalStylesVariations()?.length,
[]
return (
<SidebarNavigationItem
{ ...props }
params={ { path: '/wp_global_styles' } }
aria-current={
params.path && params.path.startsWith( '/wp_global_styles' )
}
/>
);
if ( hasGlobalStyleVariations ) {
return (
<SidebarNavigationItem
{ ...props }
params={ { path: '/wp_global_styles' } }
uid="global-styles-navigation-item"
aria-current={
params.path && params.path.startsWith( '/wp_global_styles' )
}
/>
);
}
return <SidebarNavigationItem { ...props } />;
}

export default function SidebarNavigationScreenGlobalStyles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function MainSidebarNavigationContent() {
{ __( 'Navigation' ) }
</SidebarNavigationItem>
<SidebarNavigationItemGlobalStyles
uid="styles-navigation-item"
uid="global-styles-navigation-item"
icon={ styles }
>
{ __( 'Styles' ) }
Expand Down

0 comments on commit 98a482b

Please sign in to comment.