Skip to content

Conversation

yogeshbhutkar
Copy link
Contributor

@yogeshbhutkar yogeshbhutkar commented Jun 17, 2025

What?

Closes #70447

This PR updates the style book to display the selected block variations of individual blocks.

Why?

Previously, the style book preview rendered the default view when a particular block variation was selected instead of rendering the block with the selected variation applied.

How?

The bug mentioned above happened because the block name wasn't properly extracted from the code below, as the presence of variation within the section wasn't considered.

Ref.

Testing Instructions

  1. Navigate to Appearance > Editor > Styles.
  2. Open the Style Book by clicking on the eye button.
  3. Select the Separator Block from all the blocks displayed in the preview.
  4. From the available Style Variations, click on the Dots variation.
  5. Confirm that the preview changes and adapts to the selected block variation.

Testing Instructions for Keyboard

Same.

Screencast

PR Demo

@yogeshbhutkar yogeshbhutkar changed the title [WIP 🚧] Style Book: Enable support for showing individual block variations Style Book: Enable support for showing individual block variations Jun 17, 2025
@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review June 17, 2025 08:41
Copy link

github-actions bot commented Jun 17, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: tomdevisser <tomdevisser@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] Style Book labels Jun 17, 2025
@yogeshbhutkar yogeshbhutkar force-pushed the fix-70447/storybook-variations-support branch from da802bd to 11d49ad Compare June 18, 2025 07:10
@yogeshbhutkar
Copy link
Contributor Author

Hi, @t-hamano. If possible, can you please review this PR? I have a feeling that this could be a nice improvement.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Almost everything is working correctly, but I think we need to fix what happens when you click on Preview:

c31f879f381f6af38d3c6f8a1964294d.mp4

When you click on a variation, the URL path changes, and the block that variation is based on is displayed. We may need to disable the click altogether if we don't expect navigation in the first place, but for now, let's keep the current URL path.

@t-hamano t-hamano self-requested a review June 25, 2025 13:22
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

I am temporarily removing my approval as we need to address the issues outlined in this comment.

@yogeshbhutkar yogeshbhutkar force-pushed the fix-70447/storybook-variations-support branch from 486a38e to 7347f6c Compare June 26, 2025 05:37
@yogeshbhutkar
Copy link
Contributor Author

Thanks for the review, @t-hamano!

I've implemented the suggested changes. Could you please have another look when you get a moment?

pr-demo.mov

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@t-hamano t-hamano merged commit 8a07978 into WordPress:trunk Jun 27, 2025
60 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.2 milestone Jun 27, 2025
shubhtoy pushed a commit to shubhtoy/gutenberg that referenced this pull request Jun 27, 2025
…ordPress#70448)

* feat: show individual variations when selected

* doc: clarify intent with a better comment

* chore: organize imports

* fix: don't return to base when clicked on variation preview

Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: tomdevisser <tomdevisser@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Style Book [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clicking on a style variation in the Style Book resets to the full overview instead of isolating the element
2 participants