CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
contentOnly Patterns experiment: Add Edit Contents button to block inspector and show 'Detach' block action #71653
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
Conversation
…e attribute to a block
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +495 B (+0.03%) Total Size: 1.94 MB
ℹ️ View Unchanged
|
patternName: insertedPatternId, | ||
// When a pattern is created for the first time the `categories` are missing. | ||
// This is a known issue that needs to be fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As well as adding the patternName
, we should add a categories
apparently.
The way categories works is hard for me to understand - sometimes the category id is added, sometimes the category name.
I can't figure out what categories
property does, so for now I've not added it. I'll make a follow-up issue to add it consistently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a very old repressed memory that categories here need to handle both the "default" categories (ones with a name) and those created by the user which leverage a taxonomy and end up with IDs.
A quick search dug up these that might help shine a light on the situation:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the links, that'll help for sure! I'll make sure to add them to the issue I create.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue is here - #71687
Flaky tests detected in 4175560. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/17752508496
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @talldan 👍
This is working as advertised for me.
✅ Edit contents button in BlockCard is available and working as expected
✅ Detach block action for unsynced patterns is available and works
✅ Manage patterns block action for unsynced patterns is now available
Hides the 'Create pattern' block action for unsynced patterns
Fixes an issue where patternName isn't added to block metadata when the 'Create pattern' block action is used.
Fixes an issue where block editing modes were not recalculated when the patternName attribute is added or removed.
These additional tweaks and fixes make sense to me.
I'm happy to approve this but I'm also still getting my head around all the contentOnly pattern experiments so feel free to get a second opinion.
patternName: insertedPatternId, | ||
// When a pattern is created for the first time the `categories` are missing. | ||
// This is a known issue that needs to be fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a very old repressed memory that categories here need to handle both the "default" categories (ones with a name) and those created by the user which leverage a taxonomy and end up with IDs.
A quick search dug up these that might help shine a light on the situation:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is testing great for me, too, and the "Edit Contents" button really feels like it's starting to create a nice flow here IMO 👍
const isUnsyncedPattern = | ||
blocks.length === 1 && | ||
blocks?.[ 0 ]?.attributes?.metadata?.patternName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double-checking: we don't check for the experiment here, but I assume that's safe because the block would only have the patternName
metadata if it had been added due to the experiment being added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
patternName
is also added in trunk
, so it will also apply there. The code will hide the "Create pattern" option for blocks that are already marked as a pattern. My thinking is that it's a bit duplicative. On the other hand, in trunk users can change the blocks in the pattern, so they might want to save changes as a different pattern.
Maybe it's better behind the experiment, what do you think? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and added the experiment flag here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and added the experiment flag here.
Sounds good, I don't think it's a huge issue either way for this one, but one of the other good things about adding the flag is that it highlights the different bits of the feature for us to re-test before we stabilise / remove the flag.
Looking good to me!
break; | ||
} | ||
case 'UPDATE_BLOCK_ATTRIBUTES': { | ||
// Handle unsynced patterns which indicate their contentOnly-ness via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contentOnly-ness
My favourite bit.
…when experiment is active
What?
Closes #71558
Part of #71517
Does the following when the contentOnly patterns experiment is active:
Does the following regardless of whether the experiment is active (they feel like good changes generally, but let me know if you think they should be part of the experiment):
patternName
isn't added to block metadata when the 'Create pattern' block action is used.patternName
attribute is added or removed.This ended up being more involved than initially expected, it required quite a few related changes.
Testing Instructions
First enable the experiment in Gutenberg > Experiments from wp admin:

contentOnly
mode is now not active on the pattern contentscontentOnly
.Screenshots or screencast
Kapture.2025-09-15.at.16.29.11.mp4