Block Editor: Hide Duplicate/Add before/Add after for templateLock contentOnly blocks#76894
Closed
Block Editor: Hide Duplicate/Add before/Add after for templateLock contentOnly blocks#76894
Conversation
…ntentOnly blocks `insertBeforeBlock` and `insertAfterBlock` silently bail when the parent has any truthy templateLock, including 'contentOnly'. Meanwhile, `canInsertBlockType` explicitly exempts 'contentOnly' from that check, so the menu items appeared enabled but did nothing when clicked. Gate `canDuplicate` and `canInsertBlock` in `BlockActions` and `useQuickActionsCommands` when the parent block has `templateLock: "contentOnly"`, hiding Duplicate, Add before, and Add after from the options menu and command palette. This targets templateLock specifically and does not affect unsynced patterns, which set contentOnly editing mode via a different path.
6 tasks
ramonjd
commented
Mar 30, 2026
| const directInsertBlock = rootClientId | ||
| ? getDirectInsertBlock( rootClientId ) | ||
| : null; | ||
| const isParentTemplateLockContentOnly = |
Member
Author
There was a problem hiding this comment.
Not sure, but I should check nested locked blocks just in case. Maybe a nothing burger
|
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: +29 B (0%) Total Size: 7.73 MB
ℹ️ View Unchanged
|
Member
Author
|
Not the right solution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Hides "Duplicate", "Add before", and "Add after" from the block options menu and command palette when a block is inside a parent with
templateLock: "contentOnly".Fixes #76881
Why
How
getTemplateLockis called on the parent block insideBlockSettingsDropdownanduseQuickActionsCommands. When it returns'contentOnly', Duplicate, Add before, and Add after are hidden.This targets
templateLockspecifically and does not affect unsynced patterns: they entercontentOnlyediting mode viametadata.patternName, nottemplateLock, sogetTemplateLockreturnsfalsefor them and their menu items are unaffected.Testing Instructions
See #76881 for bug description and test HTML.
"templateLock": "contentOnly"and"lock": { "move": true, "remove": true }.Cmd+K/Ctrl+K) with the Paragraph selected.Screenshots or screencast
Before
Kapture.2026-03-30.at.09.09.26.mp4
After
Kapture.2026-03-30.at.09.21.56.mp4
Use of AI Tools
Claude code developed this PR under instruction.