-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Prevent removing blocks if templateLock
is set to insert
#8201
Prevent removing blocks if templateLock
is set to insert
#8201
Conversation
I still think there's a lot of merit in #8112, especially for more complex InnerBlocks situations (programmatic management of the block structure in particular, where you might want to disable insertion so you can handle it in a more custom way, for instance), but this is a good short term fix too. |
// Prevents deletion if templateLock is "all" or "insert" | ||
// (if a user can't insert blocks they shouldn't be able | ||
// to remove them either) | ||
return templateLock === 'all' || templateLock === 'insert'; |
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.
Minor: In other places we do !! templateLock
(inserting blocks).
I think we should add a similar check to SharedBlockDeleteButton
? what do you think? in case of a template containing a shared block.
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.
Makes sense to me, on both counts. But I didn't know a template could include a shared block — how does that work?
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.
(Like, how do you know the name of the block slug to put into the template? Is it just the name you save, or a kebab-cased version of that?)
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.
Try adding a shared block to a regular post and copy the result (it should be core/block
with a ref
attribute)
The logic got changed at some point that renders most of this PR moot, however the docs are still out of date. Going to open a new PR for that. |
Description
This PR restores the original behaviour of
templateLock="insert"
, which disallows inserting and removing, but allows moving.How has this been tested?
Tested with a custom block using
<InnerBlocks />
Types of changes
Could be considered a breaking change because it changes the behaviour of this property, although it's restoring it to the original intention.
Checklist: