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. (#67550)
  • Loading branch information
ramonjd authored Dec 4, 2024
1 parent ee87766 commit c5ecfff
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

1 comment on commit c5ecfff

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in c5ecfff.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12157932685
📝 Reported issues:

Please sign in to comment.