Motivation
Provide options to lock down a region within a section so that blocks in that region cannot be added/moved/deleted.
Proposed resolution
For any locked regions in a section, all operations are forbidden by the access controller and contextual links, etc., are removed for unprivileged users.
User interface changes
Add checkboxes for each region to the section configuration form.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | layout_builder_lock-lock_regions-3314133-13.patch | 27.57 KB | brentg |
| #4 | config-menu-showup.png | 10.86 KB | jonzhang |
Issue fork layout_builder_lock-3314133
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
muriqui commentedHere's the MR as a patch for those who may want to try it out.
Comment #4
jonzhang commentedAll the lock functions are working correctly. But the configuration icon is still showing when the block is locked. And the links are not clickable neither giving error messages which may confuse the end user.
Please see screenshot attached.

Comment #5
muriqui commentedOK, updated to address a condition wherein the contextual links weren't filtered properly, and to prevent other blocks from being moved into the locked region via the "Move" menu. Also fixed the config schema and added tests.
Comment #6
swentel commentedWow, that's impressive, never thought about going that far as in locking regions :)
I'm checking the work to be done for D10 support, I'll probably start committing those things first, will come back after that to this one.
Comment #7
swentel commentedWOOOOOO, I've tested this, this is SO awesome :)
Current patch is partially broken because I've committed #3304761: Group lock settings in a details element, attached a new version to see what the test bot thinks.
Going to look at the code and tests a bit further now, this will definitely go in!
Comment #8
swentel commentedOk, I don't have any remarks on the code or tests, they look great!
The only thing I wonder is whether the UI should make the feature a bit more clearer/explicit:
This makes it a bit more clearer to me, because I can imagine people will come up with feature requests like 'But I want to only lock move or delete'. (even though I will point them to #3109715: Allow to add locks to components for that feature).
As English is not my native language, suggestions very welcome, after that, commit and release ! :)
Comment #9
dmitry.korhovIf there are no remarks and all looks great then can we have this merged?
Comment #10
dmitry.korhovComment #11
luke.leberI think that having the same granularity with override locking as default locking might make for a more robust feature here.
What about sites where owners want lesser privileged users to be able to update overridden block content, but not rearrange them?
Comment #12
dalemoore commentedThis is so awesome, and puts Layout Builder on closer parity with what WordPress can do with locking different parts of the Full Site Editor. I haven't tested this yet but will soon...
Comment #13
brentgI've added the patch from @sonfd as a file here so it gets listed on top of the page
Comment #14
chesterr commentedChanged title and added description for better user understanding.
Comment #15
panchukI want to review latest MR ASAP and deploy it in the new 2.0.x branch.
After that, we can create some RC releases with the feature.
Comment #16
panchukOkay, I finally configured the environment for the running of the tests.
I found that LayoutBuilderLockTest::testLock() fell because of the missing $blockId parameter in LayoutBuilderLockTest::checkBlockRouteAccess() method.
It looks like in Drupal 8/9 there was a way to fetch it via a magic method:
Going to investigate previous commits to the LayoutBuilderLockTest class, and maybe will find something related.
Comment #17
panchukOkay, finally I've fixed all the tests. The problem was with the body_field_block_uuid property, which was renamed in previous commits, but not updated in each place of code.
In addition, there were new style issues with the readme file. Disabled cspell checks for the maintainer's section.
Rewritten javascript of the module. Instead of jQuery, I used pure JS and removed outdated dependency core/jquery.
Comment #19
panchukMerged into 2.x, going to create RC.
Thanks, everyone for your contribution.