Skip to content

Block Editor: Try a lock menu for locking one or several blocks - #86970

Open
fcoveram wants to merge 24 commits into
WordPress:trunkfrom
fcoveram:try/multi-block-locking
Open

fcoveram wants to merge 24 commits into
WordPress:trunkfrom
fcoveram:try/multi-block-locking

Conversation

@fcoveram

@fcoveram fcoveram commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What?

A proof of concept for locking one or several blocks from a lock menu, as an alternative to the List View lock controls in #78612. It is behind a new Gutenberg experiment, "Block lock menu".

  • Lock menu: ⋮ > Lock opens on hover with All properties, Styles, Layout, Movement and Deletion. It works with several selected blocks.
  • List View lock: an unlocked row shows an open lock on hover; clicking it locks every property. A locked row always shows its lock; clicking it unlocks. Both offer Undo.
  • Toolbar lock: a locked block or pattern shows a lock button. Clicking it unlocks, or locks again once unlocked.
  • Right-click: right-clicking either lock opens the lock menu at the pointer. The ⋮ > Lock submenu offers the same options.
  • Icons: a lock for a full lock, a lock with a dash for a partial lock, and an open lock to lock. A full lock is all four properties, or three for a block without a layout, like a Paragraph.
  • Inner blocks: a lock applies to every block inside. Each inner block can still change its own lock, and unlocking it also unlocks the blocks above that hold it.
  • Styles: content and styles can't be edited, and no blocks can be added inside. The block stays selectable, but its text is read-only, its toolbar controls are hidden and its inspector is greyed out.
  • Layout: no blocks can be added, moved or removed inside, without turning the block into a pattern.
  • Unsynced patterns: the layout belongs to the pattern, so it doesn't count as a lock, and the pattern locks and unlocks like any block. Its Layout option reads "Disabled by Pattern", and the blocks inside show a disabled partial lock, "Locked by Pattern". Locking its styles hides Edit pattern, and Detach still turns it into regular blocks.
  • Synced patterns: the Layout option is disabled and reads "Disabled by Sync pattern".
  • Icons package: adds lockOpen and lockDashed to @wordpress/icons.

Why?

Locking today goes through a modal, one block at a time, and only partly reaches the blocks inside. Several tickets explore parts of a better flow. Their ideas are the input for this PR, which is a proof of concept that connects them into one flow:

How?

  • New private selectors isLayoutLockedBlock, canLayoutLockBlock, isPatternLockedBlock and getBlockLockType; the List View uses the existing getParentSectionBlock to find blocks inside a pattern. isLockedBlock also counts a locked layout, as in Block Editor: Add layout lock option to lock modal #78608.
  • New private action setBlocksLock( clientIds, { move, remove, layout, edit } ) that applies the lock to the blocks and their descendants in a single undo step.
  • The styles lock is stored as the existing lock.edit, which only Navigation and synced patterns offered so far. With the experiment it is offered for every block: canEditBlock already hides most editing UI and puts an overlay on the block, and this adds read-only RichText, a disabled inspector (DisabledWhenStylesLocked) and no block toolbar controls. The Lock item stays available on a styles-locked block, and List View keeps listing its children, except for Navigation, which keeps its own edit lock.
  • The layout lock is stored as templateLock: 'all', not contentOnly as in Block Editor: Add layout lock option to lock modal #78608, so a locked block isn't treated as a pattern section. A block with a contentOnly template lock also counts as layout-locked. An unsynced pattern's layout is left to the pattern: the lock controls don't change it or detach it, unlike Block Editor: Add layout lock option to lock modal #78608.
  • The lock options use Menu from @wordpress/ui. The block options menu is still a DropdownMenu from @wordpress/components, which a @wordpress/ui submenu can't nest in, so the options open in their own Menu anchored beside the "Lock" item, on hover, click or the right arrow key. They close as soon as the pointer moves to another item, unless it is heading to the options. This PR doesn't move the block options menu itself to Menu.
  • The List View lock is the same Button as the row's options menu toggle, in its own row cell; rows without a lock span that column. Its tooltip names the block type, "Lock Group" or "Unlock Group", says "Lock Pattern" or "Unlock Pattern" for a pattern, and "Locked by Pattern" for the blocks inside it. A new private selector, hasOwnBlockLock, tells whether a block has a lock of its own, leaving out a pattern's layout. Its right-click menu, BlockLockContextMenu, is a Menu from @wordpress/ui anchored at the pointer, shared with the toolbar lock; the context menu key opens it below the button. The toolbar lock is a plain ToolbarButton that locks or unlocks on click.
  • With the experiment, the block toolbar also shows the lock for a block inside a pattern, whose editing mode is content only, so it shows the same disabled partial lock as its List View row.
  • setBlocksLock also unlocks a property where the blocks above hold it: the styles of locked ancestors, and the templateLock of the parent that keeps a block in place. A block with no templateLock of its own takes the one of the block above it, so a layout unlock under a block that stays layout-locked is stored as templateLock: false; otherwise the attribute is removed.
  • A block whose styles are locked takes no new inner blocks (canInsertBlockType, and no appender), and the inner blocks of a styles-locked block stay selectable in the canvas (__unstableHasActiveBlockOverlayActive), except where they come from elsewhere, like Navigation or a synced pattern.
  • With the experiment off, the lock modal works as before. The one change that applies either way is isLockedBlock counting a locked layout, as in Block Editor: Add layout lock option to lock modal #78608: an unsynced pattern, or a block with its own all or contentOnly template lock, shows the existing lock icon in List View and the lock button in the block toolbar.
  • Unit tests cover the new selectors, setBlocksLock and inserting into a styles-locked block. End-to-end tests are not written yet.

Testing Instructions

Each kind of content locks a little differently, so beyond these steps, try different combinations of lock options.

  1. Enable Block lock menu under Settings > Gutenberg Experiments > Blocks, then create a post and open List View.
  2. Lock a simple block, like an Image: hover its row and click the open lock to lock it. Right-click the lock and uncheck Movement: the icon turns into a lock with a dash. Click the lock in the toolbar to unlock it.
  3. Lock a block with inner blocks, like a Group: add a Group with a Heading and a Paragraph, and lock it from its row: the blocks inside lock too, and the Heading can't be edited in the canvas. Expand the Group and click the Paragraph's lock: the Paragraph unlocks, and so do the Group's layout and styles.
  4. Lock a pattern: insert a pattern, such as a call to action, and lock it from its row: Edit pattern is hidden. Right-click the lock: Layout reads "Disabled by Pattern". Click the lock to unlock it.
  5. Lock a synced pattern: insert a synced pattern and lock it from its row. Right-click the lock: Layout reads "Disabled by Sync pattern". Click the lock to unlock it.

Screenshots or screencast

Locking an image

Lock.a.block.mp4

Locking a group block

Lock.a.group.block.mp4

Locking a pattern

Lock.a.pattern.mp4

Locking a sync pattern

Lock.a.sync.pattern.mp4

Use of AI Tools

Written with Claude Code (Claude Opus 5.5), and reviewed and tested by the author.

🤖 Generated with Claude Code

WordPress Contributor Toolkit and others added 5 commits November 17, 2026 16:19
- Open the Lock submenu with ArrowRight and move focus to its first option. The settings menu stops arrow keys natively, so the item listens for them itself.
- Keep focus in the List View row after unlocking from its lock button.
- Show the unlocked icon on the toolbar button after an unlock.
- Show the List View lock button in white on selected rows, as the other row buttons are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Store the layout lock as `templateLock: 'all'`, which keeps blocks from being added, moved or removed inside, instead of `contentOnly`, which turned the block into a pattern section with an "Edit pattern" button.
- Keep the blocks inside a layout-locked block in place when the lock of the block changes, instead of writing an explicit unlock that let them out.
- Open the Lock submenu of the block settings menu on hover, and close it shortly after the pointer leaves it.
- Use the same button for the List View lock as for the row's options menu toggle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…idth

- Show a disabled partial lock on an unsynced pattern, labelled "Locked by its pattern": its layout is unlocked by editing or detaching the pattern, not from the lock controls, and the lock controls no longer detach it.
- Hide the lock in List View and the block toolbar while the pattern is edited, and show it again on exit.
- Disable the Layout option of the lock menu for patterns.
- Span the List View lock column in rows without a lock, so every row keeps the full width of the tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added [Package] Block editor /packages/block-editor [Package] Icons /packages/icons labels Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: fcoveram <fcoveram@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

At least one ghost was discovered. ghosts represent deleted GitHub user accounts.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

@fcoveram fcoveram added [Type] Technical Prototype Offers a technical exploration into an idea as an example of what's possible [Type] Experimental Experimental feature or API. labels Nov 17, 2026
A block inside a locked regular block controls its own lock, so its List View lock button works instead of being disabled. Only blocks inside a pattern, which are edited content only, keep the disabled "Locked by" button. Replaces `getLayoutLockedAncestor` with `getParentSectionBlock`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fcoveram fcoveram removed the [Type] Experimental Experimental feature or API. label Nov 17, 2026
fcoveram and others added 4 commits November 18, 2026 10:05
The List View lock of an unsynced pattern is no longer disabled: it opens the same confirmation dialog as the block settings menu's Detach, titled "Detach pattern". Detaching removes the pattern association and unlocks every block inside it, so they are fully editable, in a single undo step. The pattern keeps its own movement and deletion locks. Adds the `detachPattern` private action.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit 146c1bd. The List View lock of an unsynced pattern is disabled again, labelled "Locked by its pattern"; the pattern is detached from the block settings menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds "Design" to the lock menu, stored as `lock.edit` and available for every block with the block lock menu experiment. A full lock now needs movement, deletion, layout (where the block has it) and design.

A design-locked block stays selectable in the canvas, but:
- its text can't be edited, and the blocks inside it are inert, selected from List View;
- its own toolbar controls are hidden, keeping the lock button and the options menu;
- its inspector controls, including the Styles tab, are shown disabled.

Design-locking a pattern freezes its content and hides "Edit pattern". The Lock item stays in the options menu of a design-locked block, and List View keeps listing its children so each can change its own lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…letion

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasmussen

Copy link
Copy Markdown
Contributor

Nice work, thanks for the PR! I took it for a quick spin:

state

What I think this PR does well: it simplifies locking drastically. That's the main piece. I'd love broader @WordPress/gutenberg-design feedback on this aspect.


Some procedural details worth working out. I don't think this should be an experiment. Experiments are for merging and shipping a feature but having it off by default. It's valid but this one feels like a PR that we can test and merge if it works out, or try something else if it doesn't. There's nuance, so not providing direction, just mentioning that this one could be on a path to landing.

The in-canvas kebab menu shows both the strength and weakness of the new Menu component: it's super nice to be able to nest block menu items in a flyout rather than simply make a super-long kebab menu. At the same time, this seems blocked on whether we apply the dark borders or not—it could possibly be temp-hacked-away rather than embraced by the componentry, but this is a challenge to solve either way.

Speaking of the new menu, is this the new menu? The flyout has a bit of a curious pausing behaviour, observe:

compare

Lock "Design" I assume is the pattern editing part. I wonder if it should be called "Styles" instead?

Renames the label, `DisabledWhenDesignLocked` (now `DisabledWhenStylesLocked`) and its class. The property is still stored as `lock.edit` and still locks editing the content and styles of the blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fcoveram

Copy link
Copy Markdown
Contributor Author

Thanks for your input @jasmussen. This PR is not ready for review yet, but I'm taking your thoughts to improve the work ✨

fcoveram and others added 11 commits November 18, 2026 12:37
- The inner blocks of a block whose styles are locked can be selected in the canvas. Each one stays non-editable through its own lock. Blocks whose inner blocks come from elsewhere, like Navigation or a synced pattern, keep them out of reach.
- Unlocking the styles of a block also unlocks the styles of the locked blocks above it, and unlocking its movement or deletion unlocks the layout of the parent that holds it in place. A pattern keeps its layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k type

- A block whose styles are locked takes no new inner blocks, and shows no appender, so a fully locked block can't be changed by adding blocks, for example to Social Icons inside a locked Group.
- The List View unlock tooltip names the block type, "Unlock Group", instead of a custom name the block may have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pattern and the blocks inside it share the List View tooltip "Locked by Pattern".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ight-click

- An unlocked block shows an open lock in its List View row on hover, focus or selection. Pressing it locks every property of the block and the blocks inside it, with a snackbar to undo.
- A full lock shows the lock icon and a partial lock a lock with a dash, in List View and the block toolbar.
- Right-clicking the lock of a locked block or a pattern opens the lock menu at the pointer.
- Replace the lockFilled icon with lockOpen and lockDashed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A locked block or pattern shows the lock icon, whether every property is locked or only some, in List View and the block toolbar. Remove the lockDashed icon.
- A pattern's own layout no longer counts as a lock in List View: its row shows the open lock on hover, pressing it locks the pattern, and pressing the lock unlocks it. Its layout stays the pattern's.
- The open lock of an unlocked row shows while the pointer is over the row or the button has keyboard focus, so it hides after unlocking once the pointer leaves.
- Add the private hasOwnBlockLock selector.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in one click

- A partial lock shows the lock with a dash again, in List View and the block toolbar, so the two lock states are told apart at a glance. Restore the lockDashed icon.
- The toolbar lock of a locked block or pattern unlocks it on click, or locks it again once unlocked, and right-clicking it opens the lock menu at the pointer.
- Share the right-click lock menu between List View and the toolbar, and stop announcing the List View lock as a menu button, since pressing it locks or unlocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Right-clicking the open lock of an unlocked block or pattern, in List View or the block toolbar, now opens the lock menu too. The List View open lock stays shown while its menu is open, also once focus moves into the menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ern"

In the lock menu, when every block whose layout can be locked is a pattern, the disabled Layout option now has the description "Disabled by Pattern", so the checkmark is explained.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A block inside an unsynced pattern now shows the lock with a dash in List View, as its content stays editable while the rest is the pattern's, instead of a disabled open lock. Selecting one shows the same disabled "Locked by Pattern" lock in the block toolbar, which until now showed no lock for content-only blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… above

A block with no template lock of its own takes the one of the block above it. Unlocking a Column inside a locked Group and Columns removed the template lock of the Column and the Columns, so both took the Group's `all` lock again, and the blocks inside the Column stayed unable to move or be removed.

setBlocksLock now stores a layout unlock as `templateLock: false` where a block above still passes a lock down, and removes the attribute otherwise. The lock of each block reads the template lock its parent passes on once the changes apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Sync pattern"

A synced pattern has no layout lock in the lock menu, as its layout is edited in the pattern itself. Its disabled Layout option now says why, like an unsynced pattern's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fcoveram
fcoveram marked this pull request as ready for review November 19, 2026 10:31
@github-actions
github-actions Bot requested review from aduth and ciampo November 19, 2026 10:32
@fcoveram

Copy link
Copy Markdown
Contributor Author

This proof of concept gathers different ideas across tickets and proposes a new mechanic for locking different types of blocks and patterns. I'd like your thoughts @annezazu @richtabor

@jasmussen

Copy link
Copy Markdown
Contributor

This is cool work. I love this part:

locking

I'm still missing the Figma-like "dots" on innerblocks when a parent is locked. I don't think we have to have them, but it's a nice industry standard that could work also here.

But mostly I love how super simple and predictable it is to lock. I even like that you absorbed granular locking here:

Skærmbillede 2026-11-19 kl  11 56 40

And I like the partially locked icon :

Skærmbillede 2026-11-19 kl  11 56 49

I'm not sure why "Layout" is greyed for me?

One thing that needs unblocking is the menu component itself:

menu

Something is awkward here. When I move fast, the hover state kinda "pauses" on the flyout menu. Is this using the right Menu component?

The second half of this is what I mentioned already, the tension betweeen the dark-bordered toolbar borders and the present incompatibility with the Menu component. I think @jameskoster has one idea of how to solve that, but mostly this is something we need a plan for, for it to land.

Nice work.

…u item

The lock options of the block settings menu stayed open for 200 ms after the pointer left the Lock item, so moving quickly through the menu paused on them. They now close as soon as the pointer moves onto another item, unless it is heading to the options across that item, the way submenus do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Mamaduka

Copy link
Copy Markdown
Member

Great experiment, @fcoveram!

It looks like we need to refactor the block Options menu to use the new Menu component, which should reduce the complexity of submenus.

I see the PR introduces edit locking; IIRC, we tried this when we first implemented block locking, but there's a lot of complexity and many ways a block can be edited. While a good experiment, I don't think it should be grouped with menu refactoring.

@talldan, @ramonjd, I think you've worked on edit-locking-related features recently. Would love to know what you think.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Icons /packages/icons [Type] Technical Prototype Offers a technical exploration into an idea as an example of what's possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants