2

I am filtering core blocks to add more functionality and I know how I can create a new section in the sidebar that is opened by default like this:

        return (
            <>
                <InspectorControls>
                    <PanelBody
                        title={ __( 'Block Attributes' ) }
                        initialOpen={ true }
                    >
                        <TextControl
                            label={ __( '<table> class(es)' ) }
                            value={ tableClass }
                            onChange={ ( newTableClass ) =>
                                props.setAttributes( {
                                    tableClass: newTableClass,
                                } )
                            }
                        />
                    </PanelBody>
                </InspectorControls>

                <Stuff />
            </>
        );

Code somewhere else:

        return (
            <>
                <InspectorControls>
                    <PanelBody
                        title={ __( 'Block Attributes' ) }
                        initialOpen={ true }
                    >
                        <SomeThing />
                    </PanelBody>
                </InspectorControls>

                <Stuff />
            </>
        );

My issue is, I like to add to this section from a totally different place in the code. When I do this and give the <PanelBody> The same title, there will be just another <PanelBody> being created instead of adding the controls to the already existing <PanelBody>.

Btw, I know there is a 'Advanced' section for id and class but I do like to create my own. Should probably be another question but I also like to know how I can move the Advanced section to the very top and open it by default. I like my own section but adding my controls to the Advanced section would also be a less desirable solution for me, I have seen plugins do that.

1
  • Did you ever find out how to do that?
    – dweipert
    Commented Jun 10 at 15:29

0

Your Answer

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

Browse other questions tagged or ask your own question.