admin管理员组

文章数量:1122846

I want to disable blocks based on some condition eg. An instance of that block is already present in the InnerBlocks (duplicate block). When the user opens the inserter (Quick or in the sidebar Sidebar), they will see all the eligible blocks as well as the disabled blocks but their icon will be "dimmed" and they cannot be inserted, similar to WooCommerce's Checkout Block (as shown in the pic below).

I know I can modify the allowedBlocks property of the InnerBlock dynamically to control what gets to be inserted. But that method completely removes the block from the inserter. Whereas I need to show the disabled block too, but as "dimmed".

I tried to find how they did in WooCommerce Block's source code but I am unable to find it.

本文标签: Disabling blocks in the Gutenberg block Inserter