Custom Gutenberg Block: Excluding an allowed block from InnerBlock’s templateLock={‘all’}

Question

The title pretty much says it all. I am working on a custom Gutenberg block that utilizes the InnerBlocks component and I have defined some allowed and default blocks. I also have templateLock set to all so the user cannot add, remove or move blocks around. However, this settings is affecting the core/buttons block and your ability to add a new button (since this block made up of individual core/button blocks).

Is there any way around this? Is there a way to specifically exclude the core/buttons blocks from the templateLock setting?

Below you will find my edit function for the block.

edit: function (props) {
    const { className, clientId } = props;

    /**
     * Add Item
     */
    const onRemoveItem = () => {
        setAttributes({ items: parseInt(`${items}`) - 1 })
        removeBlock(clientId)
    }

    return (
        <Fragment>
            <div className="listicles-innerblocks" >
                <InnerBlocks
                    template={[
                        ['core/cover'],
                        ['custom/listdt'],
                        ['core/buttons'],
                        ['custom/listdd'],
                    ]}
                    allowedBlocks={[
                        ['core/cover'],
                        ['custom/listdt'],
                        ['core/buttons'],
                        ['custom/listdd']
                    ]}
                    templateLock={'all'}
                />
            </div>
        </Fragment>
    );
},

0
Ebonie Butler 2 years 2022-03-16T09:21:42-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse