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

Block Pattern: Shuffle option doesn't appear when inserted with / in WP 6.6 RC #63068

Open
laurelfulford opened this issue Jul 2, 2024 · 3 comments
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended

Comments

@laurelfulford
Copy link
Contributor

Description

When you insert a unsynced pattern using /, the shuffle button doesn't appear in the block toolbar. When you insert the same pattern with the + button in the top right corner, it does appear. I'm not sure if this difference is intentional, or which is right.

Step-by-step reproduction instructions

  1. Using the latest WP 6.6 RC (I tested with RC 2), make at least one unsynced block pattern that's inside of a group block, and give it a category.
  2. Insert the pattern into a page using the / shortcut. Note that the shuffle button doesn't appear.
  3. Insert the pattern into a page using the + button in the top left corner. Note that the shuffle button does appear.

If you view source, the pattern inserted the second way will have something similar to this in the code, but the pattern inserted with / will not:

"metadata":{"categories":["tester"],"patternName":"core/block/16","name":"Another awesome Pattern"}

Screenshots, screen recording, code snippet

Screen.Recording.2024-07-02.at.2.08.44.PM.mov

Environment info

WordPress version: 6.6-RC2 (Gutenberg not installed)
Theme: Twenty Twenty Four

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

@laurelfulford laurelfulford added the [Type] Bug An existing feature does not function as intended label Jul 2, 2024
@annezazu annezazu moved this to 📥 Todo in WordPress 6.6 Editor Tasks Jul 2, 2024
@akasunil akasunil added the [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced label Jul 3, 2024
@richtabor
Copy link
Member

Curious. I'm pretty sure pattern shuffling relies on pattern insertion, so that shuffling is contained to the current category of patterns.

@kevin940726
Copy link
Member

Insert the pattern into a page using the + button in the top left corner. Note that the shuffle button does appear.

The patterns inserted by this method will still have their categories intact because selectedCategory is undefined.

if (
clonedBlock.attributes.metadata?.categories?.includes(
selectedCategory
)
) {
clonedBlock.attributes.metadata.categories = [
selectedCategory,
];
}

We can do the same for patterns inserted by autocompletion, but I'm not sure if this is the desired behavior in the first place? Maybe @ntsekouras will know more? 🙇

@ntsekouras
Copy link
Contributor

It seems the addition of the metadata that are required for the Change design (now in trunk) were only added in the main inserter. We could probably do something similar in getInserterItems but I'm not sure about all the details here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended
Projects
No open projects
Status: 📥 Todo
Development

No branches or pull requests

5 participants