Restrict copy/paste of a block in the editor when supports.multiple = false
and supports.removal = false
#53471
Labels
[Feature] Blocks
Overall functionality of blocks
Needs Technical Feedback
Needs testing from a developer perspective.
[Type] Enhancement
A suggestion for improvement.
What problem does this address?
Hello folks 👋🏼 we have a custom block that should always be on the page, should not be moved, and should not be removed. To accomplish this,
supports.removal = false
andsupports.multiple = false
inblock.json
. As well, the block pattern that provides the custom block to all posts restricts removing and moving the block.The problem is that you are still able to copy and paste the block. This leads to a strange user experience. Since multiple is false, a message is given to the user after they paste the block that only 1 of the block is supported. However, because removal isn’t supported, the user cannot delete the pasted block. Only Undo seems to work.
What is your proposed solution?
It could be helpful for this issue if the combination of
supports.multiple = false
andsupports.removal = false
meant Copy and Paste of the block is not supported in the editor.Right now, with those settings, copy and paste is still enabled and available via menu, and this seems expected when viewing the source.
gutenberg/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js
Lines 295 to 298 in b0dbcf8
gutenberg/packages/block-editor/src/components/block-settings-menu/block-settings-dropdown.js
Lines 299 to 310 in b0dbcf8
Notice
canDuplicate
is only influencing the Duplicate button and theCopyMenuItem
exists without condition. I thought maybe a conditional existed earlier, but I checkedonCopy
and that doesn’t seem to be the case either.gutenberg/packages/block-editor/src/components/block-actions/index.js
Lines 134 to 142 in b0dbcf8
So that’s what brings me here today. I’m curious if it would be as simple as adding a check on the copy button that is influenced by the
supports.multiple
inblock.json
. Similar to how it seems to work for Duplicate support.Anyways, thanks for your time and I look forward to working together on this issue 😁
The text was updated successfully, but these errors were encountered: