-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Block Editor: Allow disabling content-only editing for unsynced patterns #75457
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
base: trunk
Are you sure you want to change the base?
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
1 similar comment
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
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. |
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.
Pull request overview
Adds a new block editor setting (contentOnlyPatternSections) to allow opting out of content-only editing behavior for unsynced pattern sections (blocks with attributes.metadata.patternName) in contexts like the post editor, while preserving existing behavior by default.
Changes:
- Allowlist
contentOnlyPatternSectionsthrough editor settings so it reaches the block editor store. - Gate “unsynced pattern section” logic in
isSectionBlockand derived editing mode computation based on the new setting. - Add/extend unit tests to validate selector behavior and reducer-derived modes when the setting is disabled.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/editor/src/components/provider/use-block-editor-settings.js | Passes through the new contentOnlyPatternSections setting via the editor settings allowlist. |
| packages/block-editor/src/store/reducer.js | Updates derived editing mode computation and UPDATE_BLOCK_ATTRIBUTES handling to respect contentOnlyPatternSections. |
| packages/block-editor/src/store/private-selectors.js | Updates isSectionBlock so patternName blocks stop being treated as sections when the setting is false. |
| packages/block-editor/src/store/test/reducer.js | Adds tests ensuring no derived modes are created for unsynced patterns when the setting is disabled. |
| packages/block-editor/src/store/test/private-selectors.js | Adds tests for isSectionBlock behavior under the new setting, including template parts and synced patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Size Change: +54 B (0%) Total Size: 3.02 MB
ℹ️ View Unchanged
|
…ntent-only pattern sections Introduce a new `contentOnlyPatternSections` block editor setting (default `true`) that themes and plugins can set to `false` via the `block_editor_settings_all` PHP filter to globally disable content-only editing mode for unsynced pattern sections. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
05a3928 to
5e87cc8
Compare
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.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/editor/src/components/provider/use-block-editor-settings.js
Outdated
Show resolved
Hide resolved
| const contentOnlyPatternSections = | ||
| nextState.settings?.contentOnlyPatternSections !== false; |
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 think the confusing aspect for me is, why does it only remove contentOnly from unsynced patterns?
What about template parts or synced patterns?
That's very inconsistent.
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.
Synced patterns are a completely different paradigm. They sync their design changes across all instances. So editing them inline is not the best experience as we have found out when we enabled it a while ago. So friction in editing the design parts of synced elements IMO is a good thing.
|
Thanks for the PR! I'm personally a fan of options, so the PR is completely reasonable in that respect. To start, I'd briefly expand this paragraph, as I feel it's lacking slight nuance:
You can still freely edit all blocks inside unsynced patterns with this behavior:
I expect these flows to be refined further as well. I would also add that the curation mechanism that this feature suggests can be extremely useful in a post editor context. As an example I could imagine designing a pattern for my website that I use in every post, a "TL:DR;" list that I insert at the top of, featuring a list block and a decorative bullet. Or perhaps a particular layout for a gallery that I intend to reuse, two columns, visually offset, left one has the caption below, right one has the caption above. In both these examples, I'd want the per-post art direction capabilities of not using synced patterns with overrides. And in both examples, I don't think of these patterns as patterns, I think of them as custom blocks that I made by piecing together other blocks. Which is exactly the point. None of that invalidates your point, but I share it as pretty important nuance to explain that the feature is not intended just for site editing, it's intended to elevate the pattern building experience across the board. And with that said, to me personally (but this is not a decision, which I would expect can be arrived at from plenum agreement instead), it's entirely reasonable to provide a settings level opt-out to this. |
…Sections Flip the setting semantics so undefined/false (the default) means content-only sections are enabled, removing the need for `!== false` checks. Setting `disableContentOnlySections: true` explicitly opts out. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…PDATE_SETTINGS Use !! coercion so that equivalent falsey values (undefined, false) don't trigger unnecessary derived-mode tree recomputes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@jasmussen thanks as always for your thoughtful comment :) I agree my initial description was a bit over simplistic so I've refined it a bit 👍 :) |
What?
Adds a new
disableContentOnlySectionsblock editor setting that allows opting out of content-only editing mode for unsynced pattern sections.Why?
Closes #71573
Currently, blocks with a
patternNamein their metadata are automatically treated as section blocks, which puts them into content-only editing mode. This restricts what users can edit within those patterns. Whilst this is generally something I think is really important for us to work on, in its current implementation it also adds a lot of friction to editorial teams that are constantly jumping from section to section. And having to hit the "Edit Section" button multiple times is undesirable.How?
The new
disableContentOnlySectionssetting defaults toundefined/false(preserving existing behavior, with content-only sections enabled). When set totrue:isSectionBlockselector: Blocks withpatternNamemetadata are no longer treated as section blocks. Template parts and synced patterns (core/block) remain unaffected.getDerivedBlockEditingModesForTree: Unsynced patterns are excluded from the content-only parent list, so nocontentOnlyediting modes are derived for their children.withDerivedBlockEditingModesreducer: TheUPDATE_BLOCK_ATTRIBUTEShandler skips pattern-related editing mode derivation entirely. TheUPDATE_SETTINGShandler compares effective boolean values (via!!coercion) to avoid unnecessary tree recomputes when the raw value changes between equivalent falsey states (e.g.undefinedtofalse).The setting is passed through from the editor settings via the
BLOCK_EDITOR_SETTINGSallowlist inuse-block-editor-settings.js.Testing Instructions
disableContentOnlySections: trueis set in the block editor settings, insert an unsynced pattern and confirm all inner blocks are fully editable (not restricted to content-only mode).core/block) still behave as section blocks regardless of the setting value.Testing Instructions for Keyboard
No UI changes — this is a settings-level opt-out. Keyboard accessibility is not affected.