WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.5k stars 4.2k forks source link

On Patterns screen for classic theme, site icon does not return to admin dashboard on mobile #66844

Open ironprogrammer opened 15 hours ago

ironprogrammer commented 15 hours ago

Description

With a classic theme active, clicking the site icon to return to the admin dashboard yields a different result between desktop and mobile.

On desktop, the site icon returns to the dashboard. On mobile, however, it opens the site editor sidebar menu, revealing other screens that are not compatible with non-block themes. For instance, a blank page results when attempting to access Styles. The issue appears to have been introduced in 6.6 when the Patterns link was updated to resolve in the site editor.

What I expected

The expected result is that on mobile screens (728px or narrower) the site icon should return to the admin dashboard, like on desktop.

Props @kebbet for raising this in the #core channel.

Step-by-step reproduction instructions

  1. Open WordPress 6.6+ on a mobile device, OR on desktop, shrink the viewport to 728px width or less.
  2. Activate a classic theme, such as twentytwenty.
  3. Navigate to Appearance > Patterns.
  4. Inspect the site icon (typically the WordPress "W") in the upper left, and observe that it is the "Go to Site Editor" button (via aria-label attribute).
  5. Click the site icon and observe that the left site editor panel opens.

Here are some test links that activate classic theme twentytwenty and navigate to the Patterns screen directly:

Screenshots, screen recording, code snippet

Animated GIF demonstrating clicking the site icon when viewing the Patterns screen with Twenty Twenty activated: Image

Environment info

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Please confirm which theme type you used for testing.

yogeshbhutkar commented 2 hours ago

I believe the mobile site hub menu's WP Button has some old code that just navigates back.

<Button
    __next40pxDefaultSize
    ref={ ref }
    label={ __( 'Go to Site Editor' ) }
    className="edit-site-layout__view-mode-toggle"
    style={ {
        transform: 'scale(0.5)',
        borderRadius: 4,
    } }
    onClick={ () => {
        history.push( {} );
        navigate( 'back' );
    } }
>
    <SiteIcon className="edit-site-layout__view-mode-toggle-icon" />
</Button>

If we fetch the dashboard link, assign it to the href, and remove the onClick handler, the issue will then be resolved.

I would like to take up this issue and come up with a corresponding PR.