title: Add or delete blocks programmatically while template locked, Gutenberg
body: <p>I am using the <a href="https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/#template" rel="nofollow noreferrer">templateLock</a> property to lock down the template of an inner block:</p>
  <pre><code>edit: () =&gt; {
       return (
           &lt;InnerBlocks
               template={ MY_TEMPLATE }
               templateLock=&quot;all&quot;
           /&gt;
       );
   },
  </code></pre>
  <p>I am not allowing to insert new blocks or delete them.</p>
  <p>However I would like to add or delete blocks programmatically, for example using:</p>
  <pre><code>wp.data.dispatch(&quot;core/block-editor&quot;).removeBlock( blockClientId );
  </code></pre>
  <p>This does not work because the template lock prevents all operations. Is it possible to lock the template but still be able to add/delete the child blocks programmatically?</p>
  <p>I know it is possible to lock individual blocks with the new <a href="https://make.wordpress.org/core/2022/01/08/locking-blocks-in-wordpress-5-9/" rel="nofollow noreferrer">lock attribute</a>, but this adds a lock icon to the blocks, also the possibility to uncheck locking. I do not want the user to see any add or delete block UI, or be confused by the lock icon.</p>