ContentOnly: For template parts and synced patterns, ensure 'Edit section' button goes to the isolated editor#73736
Conversation
|
Size Change: +527 B (+0.02%) Total Size: 2.57 MB
ℹ️ View Unchanged
|
|
Thanks for getting this PR up so quickly!
I'd vote to add them back in, especially now that template part editing is remaining in isolated "mode". I think if we're deliberately taking something away from users, there should be a pretty good reason. Is there one? Unless the design switcher itself is seen as having little or no value. I get that editable fields might be a thing one day. Is it thinking too far ahead to leave that space blank in case that feature lands? I'm sure @fcoveram will have better insight! |
+1 Thanks for looking into it. I'm sure we'll hear about it if it doesn't work after merge 😄 |
|
Update: in d5dcb5f I've pushed a change to allow the slot and advanced controls for template parts (and technically for synced blocks, but they don't actually have those). The result is that we get a hybrid where we're still treating template parts as section blocks and therefore showing the content buttons to select inner blocks, but we also expose the Design and Advanced controls, allowing local changes for the instance of the template part. Here's how it looks: 2025-12-05.12.25.51.mp4I think this provides a pretty good balance, as it means we've (hopefully) kind of get the best of both worlds of content only controls, being able to click Edit Section to go to the isolated editor, while also allowing the advanced controls. A byproduct of how I've done this is that some settings of blocks can be exposed in the inspector panel while selected. Like selecting a site icon or toggling settings for the site title. This felt pretty good to me, but happy to look into scaling / rolling this part back if it feels like too much. I believe this is ready for review. Good things to test are that it's working correctly, but also smoke test with the experiments switched off to make sure that I haven't accidentally exposed anything here that shouldn't be. Thanks! |
|
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. |
|
I think the e2e failure is legit, I'll look into it. So the code here might not be final, but should be in a good place to see how it feels to use. If I don't get time to fix this PR properly today, I'll continue on with it on Monday. |
|
Alrighty, I believe I've fixed it in a580576 by making this behaviour a bit more restricted. That is, we only inject InspectorControls and AdvancedControls if the root section is what's selected. That addresses the main case we want to handle. Here's how it's looking now: 2025-12-05.14.17.51.mp4Note that in the above video the template part itself will expose the Design and Advanced controls (in addition to the selectable blocks within Content). And then if you select blocks within a synced pattern, it does not expose settings and advanced.
On second thoughts, I think refactoring might be best in a separate PR as some of the names in the parent component are a bit confusing. This should be ready for review now 🤞 |
| const shouldNavigateToIsolatedEditor = | ||
| ( isSyncedPattern || isTemplatePartBlock ) && onNavigateToEntityRecord; | ||
|
|
||
| const handleClick = () => { |
There was a problem hiding this comment.
Is this duplicated above in edit-section-menu-item.js?
My eyes could be deceiving me!
There was a problem hiding this comment.
It sure is! Nearly identical. I kept it non-DRY while hacking this together (happy to consolidate 👍)
There was a problem hiding this comment.
Cheers! I'll leave my glasses prescription upgrade for next year then.
This is an interesting one, thanks for testing @ramonjd! This isn't that the template part itself is in content only mode, it's that the template part contains a pattern for its markup, and because of that, to the user, it effectively looks like the template part is in content only mode. But it's actually because the template part contains a pattern. I.e. if I go to view the source of my template part, I see a wrapper group block with the patternName: So I think the question here is: what should we do about contentOnly mode when we're in the isolated editor? Should we switch it off entirely? I think we probably should. We can even test it on trunk if we go to the Site Editor > Patterns > All template parts, and then select a header, you get this weird experience: 2025-12-05.16.02.40.mp4So yeah, I think the next step will be to disable it in the isolated editor, if that sounds reasonable to folks? I can dig into that idea next week. Given that this PR is changing what Edit Section does, I think it makes sense to roll it into the work in this PR (and that it feels pretty broken without it) Let me know if anyone has other ideas, though! |
Oh, 😄 sorry that should have occurred to me
I agree with you: that we should. I think it could get confusing for users to have to drill down twice. Just my 2c Thanks for investigating 🙇🏻 |
No need to apologies, neither of us thought of it! I appreciate the 🦅 👀 |
a580576 to
fc6cdda
Compare
|
Alrighty, I've pushed another change in fc6cdda that flags if we're in the isolated editor I'm not sure if this is the best approach, but it's the best I could come up with on a Friday afternoon — I think we need a way to tell the block editor that it's in an isolated editor mode, and therefore to skip the logic that locks down unsynced patterns / treats them as contentOnly mode. That is, when editing template parts / synced patterns directly, we don't want to guard users from making edits. To do so, I had to add a key to the editor settings and pass it from the editor... again, not sure if there's a better way to do it. But at least it seems to be working pretty well now (I'll likely need to update tests again). Here's another look at the state of this PR: 2025-12-05.16.59.47.mp4I'll continue on with this next week with fresh eyes, but as always, happy for feedback and ideas! (As an aside, I noticed the Back button in the document bar sometimes doesn't appear to work on first click... not sure what's going on there or if it's an existing bug) |
There is already an issue about this with lots of discussion - ContentOnly experiment: Template Parts with nested patterns appear locked when clicking 'Edit' from the toolbar. This is one of the problems with the focus mode. The spotlight editing mode by comparison unlocks everything within a section. For focus mode, because it's such a separate experience it's a little harder to achieve that. |
Thanks for linking! The discussion there seems a little inconclusive, but I can add a comment over there, too. This PR is really just hacking on the idea of seeing how we could make the isolated editor feel good for template parts / unsynced patterns. I'm not sure we've achieved that, so consider this PR very much an exploration 😄
Yeah, it's a challenging one. I've hacked this PR in to try to disable contentOnly mode altogether while in a focused mode / isolated editor to see how it feels. My hunch is that if someone is editing a template part or synced pattern in focused mode, maybe it's better that we don't really use contentOnly mode at all... Happy to close out this PR if there's a better approach! |
Yes, that's my hunch too, but I think how it's achieved is the unclear part. I think there is a bigger picture in a sort of editor design mode that could be used for this, but it's too soon, so perhaps something temporary and non-controversial will work. |
talldan
left a comment
There was a problem hiding this comment.
A few comments, but nothing major!
packages/block-editor/src/components/block-inspector/edit-contents.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-inspector/edit-contents.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/block-inspector/edit-contents.js
Outdated
Show resolved
Hide resolved
| // When editing template parts, patterns, or navigation in the isolated editor, | ||
| // we're in an isolated editing context (focused on that entity alone). | ||
| const isIsolatedEditor = | ||
| params?.postId && FOCUSABLE_ENTITIES.includes( params?.postType ); |
There was a problem hiding this comment.
This approach makes sense to me, though FOCUSABLE_ENTITIES also includes navigation, so I'm wondering if that causes any unexpected side effects. Maybe it's ok because the nav block isn't a section.
There was a problem hiding this comment.
On second thoughts, we shouldn't need this code in edit-site as the logic as already being handled at the editor package level. I'll remove the changes to this file.
| 'wp_template_part', | ||
| 'wp_block', | ||
| 'wp_navigation', | ||
| ].includes( postType ); |
There was a problem hiding this comment.
I think you can read the value from settings, I don't think you need to calculate it again.
Every key in the BLOCK_EDITOR_SETTINGS array should be forwarded, but it might not work for symbol keys. The code here is what handles it:
Another option might be adding an extra line or two to the above code so that isIsolatedEditorKey isn't filtered out, though maybe it's never actually part of the entries() in the first place 🤔 .
There was a problem hiding this comment.
It turns out I think this is where we want to calculate it, rather than in edit-site, so I've gone with retaining this code. I'll move it up to the const blockEditorSettings for consistency, though.
Also, I've included wp_navigation as it also uses the isolated editor. Given that editing navigation post types is also quite a granular kind of editing, I think it makes sense to skip contentOnly mode for unsynced patterns there, too. Though I assume it's fairly unlikely for unsynced patterns to make it into being within a wp_navigation, it's probably good to be consistent.
Fantastic, thanks for the comments and review Dan, that's super helpful! I'll work through these notes 👍 |
…tion' button redirects to the isolated editor instead
…nd advanced when the section block itself is selected
fc6cdda to
8ed1544
Compare
|
Flaky tests detected in 955301f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/20053167166
|
… have clearer distictions from each other
Co-authored-by: Daniel Richards <daniel.richards@automattic.com>
|
Good feedback again @talldan, cheers. I think I've worked through it all now, so this should be ready for another look. Do let me know if there's anything I missed, though! |
Oh, good observation! I'd probably consider this something to dig into in subsequent PRs, but I wonder if it'd be worth trying to either:
Not too sure, just spitballing ideas for how to make it easier to select the outer wrapper. I'm not sure we should try to expose the parent's tools (design, advanced) directly to the inner block unless we really have to, though, as it could get a bit tangled... but maybe it's not as complex as I fear. In any case, good ideas to play around with! I'm a bit time-limited this week, so I might park working on figuring that out for now. Let me know if there's anything anyone thinks should still be addressed in this PR, though. |
This one sounds more intuitive to me. But yeah definitely something for another PR! |
tellthemachines
left a comment
There was a problem hiding this comment.
This LGTM and is working well! Just a couple questions below, nothing blocking.
|
Just added a comment. If there aren't any objections, I can look into merging this tomorrow. (Also happy to keep iterating if there are any concerns, of course) |
Let's do it! Great stuff |





What?
Part of:
Update the Edit Section button to be aware of whether a block is a synced pattern or template part. If so, clicking the button will redirect to the isolated editor.
Why?
As discussed in #73677 this ensures that items edited in situ (unsynced patterns) are clearly edited within their context, and symbols (template parts, synced patterns) are edited in their own location. This better indicates the scope of changes someone might make (i.e. am I just changing this part of one page, or all instances of this thing)
A caveat / question ❓A decisionNote that this PR currently means that the controls for changing the template part design are no longer available. What could or should we do about that? I.e. before this PR, when we clicked the Edit Section button, we could access these:
Update: see the comment in #73736 (comment) — I've gone for a kind of hybrid where we show the content buttons and the Design and Advanced panels so that we prioritise the content only experience while also allowing local edits for template parts. I think this might give us a compromise between the behaviours.
How?
Testing Instructions
Screenshots or screencast
edit-section-button.mp4