WordPress / gutenberg

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

Styles panel content shift from "Browse styles" link #58582

Open ironprogrammer opened 7 months ago

ironprogrammer commented 7 months ago

Description

In a block theme, after opening the Styles panel, there is a ~1 second delay before the "Browse styles" link appears, which shifts the Typography/Colors/Layout links down by 60+ pixels. This delay often (for me) results in an unintentional click on the newly materialized "Browse styles" link, instead of e.g. Typography.

I would expect the "Browse styles" link to appear more quickly (it's the only link in this panel with a delay), or if the delay is required for async processing, for there to be a placeholder or padding to prevent the resulting content shift.

Workaround: Slow down with the pointer when using this panel šŸ˜‚ However, this is the only place in the UI that I encounter this regularly, and it's just slow enough of a delay to be frustrating.

Step-by-step reproduction instructions

  1. With a block theme active, open Appearance > Editor.
  2. Click in the editor area to activate it, then click the Styles icon to display its panel.
  3. In under ~1 second, click the Typography link.
  4. Observe that at a normal pointer movement speed, the click could activate "Browse styles" instead.

Screenshots, screen recording, code snippet

There is enough time to open Styles, wiggle around Typography, and then click -- which by this time Typography has shifted down and an unintended screen is loaded instead. Getting back to the Styles panel can take time due to latency in loading the style variations. browse-styles-typography-content-shift

Environment info

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

Yes

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

Yes

ironprogrammer commented 7 months ago

Since updating GB trunk today (last commit 38fbc7f986df16545d31e0f21344cb1b22c42f06), this experience has improved greatly, though not completely mitigated.

In testing today, the display of "Browse styles" has ranged from "instant" to a barely perceivable delay. However, it's fast enough that mis-clicking is much harder. I've leave this open in case there are others who might share their experience.

Here is a demonstration that the appearance of the link is much faster: styles-content-shift-improved

aaronrobertshaw commented 5 months ago

if the delay is required for async processing, for there to be a placeholder or padding to prevent the resulting content shift

The UI component is rendered once there are theme style variations available within the core store. Those theme style variations are requested asynchronously via the REST API resulting in the delay and content shift seen.

I'm not sure we can get away with a placeholder as it could create dead space for themes that have no variations. Perhaps the presence of theme style variations is something that could be added to the editor settings sooner to avoid having to rely on the async check.

ironprogrammer commented 5 months ago

Thanks for taking a look at this, @aaronrobertshaw. Loading earlier to avoid the shift could work.

Another thought might be to integrate the styles options into the existing style sample div. This is purely decorative (non-interactive) at this time, correct? Because this div always displays with the default style (even when no variations are available), when additional styles become available, it could perhaps add or become the link to browse styles?

Move styles browser link into style sample div example

After the styles load, it could animate to move the "Aa" content upward, and add the browse link. OR, maybe better, just make this whole div the link when additional styles are available (presuming some added indicator for users to click/peruse)? It could become the style variation "button".

aaronrobertshaw commented 5 months ago

Another thought might be to integrate the styles options into the existing style sample div.

Could be worth exploring šŸ‘

I've added the needs design label to the issue to get some broader input before diving in too deep.