WordPress / gutenberg

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

Block variations transformations only going in one direction #52584

Open AlchemyUnited opened 1 year ago

AlchemyUnited commented 1 year ago

Description

I have two variations of core/paragraph. For the sake of this issue, I'll call them Blue Paragraph and Red Paragraph. I can, via scope (in erach variation), add the select in the block setting pallet (in the right sidebar) for picking a variation. Via that select, I can transform from core/paragraph, Blue paragraph or Red paragraph to Blue or Red, but not to core. That is, for example, I can't transform from Blue Paragraph back to the core/paragraph.

I've read the following looking for a solution:

https://github.com/WordPress/gutenberg/pull/26687

https://gutenberg.10up.com/reference/Blocks/block-variations/

https://developer.wordpress.org/block-editor/reference-guides/block-api/block-variations/

https://richtabor.com/block-variations/

And didn't see any mention of how to do this. Maybe it's not a code bug, but a documentation bug in that it's not explained how to achieve this?

It may help to know, my hope is to setup very specify blocks & variations that reflect the client's style guide. Yes, I understand I can define a color pallet, but there's currently no way to control color combos within that set of colors; specific combos that are defined in the brand style guide. In addition, this enables the client's team to focus on content and layout and not have to worry - at all - about maintaining the style guide. The blocks and block variations limit them, in a good and desired way.

Step-by-step reproduction instructions

Here's a quick & dirty of my two (test) variations:

wp.blocks.registerBlockVariation( 'core/paragraph', {
    name: 'custom',
     title: __( 'Blue Paragraph' ),
     description: __( 'My new Blue Paragraph' ),
    attributes: { providerNameSlug: 'custom', className: 'is-style-blue-p4' },
    scope: [ 'inserter', 'transform' ],
});

wp.blocks.registerBlockVariation( 'core/paragraph', {
    name: 'custom2',
     title: __( 'Red Paragraph' ),
     description: __( 'My new Red Paragraph' ),
    attributes: { providerNameSlug: 'custom2', className: 'is-style-red-p1' },
    scope: [ 'block', 'inserter', 'transform' ],
});

Screenshots, screen recording, code snippet

No response

Environment info

Latest version of WP, not using the Gutenberg plugin.

Firefox on Win 10 Pro, tho' I don't feel these are part of the problem.

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

github-actions[bot] commented 1 year ago

Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.