0

currently i am developing a block and i am trying to use an experimental API __experimentalCaptureChildToolbar (see https://github.com/WordPress/gutenberg/pull/18440). This should be included in 7.2.0 of Gutenberg. It seems however unable to really tell which version is included in Wordpress (What version of Gutenberg is included with WordPress?) but i am using Wordpress 5.5.1 so it should be fine.

I was trying to simply use it like done one the navigation block, https://github.com/WordPress/gutenberg/blob/7.2/packages/block-library/src/navigation/edit.js. However it did not change anything.

I am not sure how the navigation block works (and if) as it is also experimental, from what i can see. I could not get any documentation or information via Google on how to turn on those experimental blocks. Can anybody help?

From what the documentation and all the sparse info i could find on the web on __experimentalCaptureChildToolbar is it should be easy to just use it. Anybody has any guidance on how to use or has implemented it him-/herself?

Thank you.

P.S: There's not much to the code than adding the attribute

edit: function( props) {
    ...
    return (  
        <>
        <Toolbar>...</Toolbar> 
        <InnerBlocks
            template={ slidesTemplate }
            templateLock="all"
            allowedBlocks={ allowedBlocks }
            __experimentalCaptureToolbars={ true }
        />
        </>
    );
}
2
  • 1
    What are you expecting it to do, and what happens instead? Keep in mind as this is experimental, it will go away in the future
    – Tom J Nowell
    Commented Sep 3, 2020 at 10:12
  • Sure i know that, thank you. Well i expect the parent toolbar to be displayed while the children are active (as the name and doc implies) but at least some visual change. It does not. From what i have seen it should at least use a class has-toolbar-captured which from what i can see is not used while the toolbars are active.
    – patman
    Commented Sep 4, 2020 at 15:19

1 Answer 1

1

https://github.com/WordPress/gutenberg/blob/2d7e6904cee90a92bf1fc60467d1c6bb03654656/packages/block-editor/src/components/inner-blocks/README.md#__experimentalcapturetoolbars

Determines whether the toolbars of all child Blocks (applied deeply, recursive) should have their toolbars "captured" and shown on the Block which is consuming InnerBlocks.

For example, a button block, deeply nested in several levels of block X that utilises this property will see the button block's toolbar displayed on block X's toolbar area.

That seems to be it, a true or false value, there are no other ways to use it.

Note, that as an experimental API, this prop will not be available in the future, either because it was removed, or because it's no longer experimental and is renamed. I strongly advise against using it in production code for that reason.

Additionally, because it is experimental, that is not a guarantee that it will work, afterall, it's experimental code.

1
  • Thank you. Reading it again i have probably missunderstood the functionality, as i thought you could add some parent functionality to the toolbar as well. Checking it again it looks like it works. Although i still would love to highjack some part of the toolbar from the parent. WIll not go to production of course should have mentioned that.Do you might have a hint on how to determine the gutenberg version and to enable experimental blocks in a wordpress install?
    – patman
    Commented Sep 4, 2020 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.