Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: use active variation as the parent block if available #44609

Conversation

dinhtungdu
Copy link
Contributor

@dinhtungdu dinhtungdu commented Sep 30, 2022

What?

This PR shows the active variation info in the inner block's menu if the parent block is a variation.

Why?

Fixes #44608

If the current parent block is a variation, it's better to display the variation title and icon in the block menu. Otherwise, it can make users confused.

How?

This PR checks if the first parent block is a variation and then uses the active variation as the parent block, so the correct metadata is displayed in the block menu: Select parent block (...) item.

Testing Instructions

  1. Add a Row block to the page.
  2. Add a Heading block to the Row block.
  3. Open the menu of the Heading block.
  4. See Select parent block (Row).

Or check out this PR, add a filter block to the page and check the block menu of inner block as screenshots show: woocommerce/woocommerce-blocks#6978

Screenshots or screencast

Before this PR

Screen Shot 2022-09-30 at 16 20 21

With this PR

Screen Shot 2022-09-30 at 16 18 10

Copy link
Contributor

@carolinan carolinan left a comment

Choose a reason for hiding this comment

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

I tested this by adding a row group block variation with a paragraph inside.
Before: The menu would show "Select parent block (group)"
With PR: The menu shows "Select parent block (row)"
The pr works well in my test.

@dinhtungdu
Copy link
Contributor Author

I tested this by adding a row group block variation with a paragraph inside.

Using Row is much easier for testing. I updated the reproduce steps using yours, thank you so much!

Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @dinhtungdu !

@ntsekouras ntsekouras merged commit 065c1ae into WordPress:trunk Oct 7, 2022
@github-actions github-actions bot added this to the Gutenberg 14.4 milestone Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The active variation isn't used as the parent block in the block dropdown menu
3 participants