Support » Plugin: Gutenberg » How to have a PluginDocumentSettingPanel initially opened?

  • Resolved Benny

    (@bvl)


    I have added a PluginDocumentSettingPanel plugin to my WP plugin.
    Is there a way to have the panel initially opened?

    
    const { registerPlugin } = wp.plugins;
    const { PluginDocumentSettingPanel } = wp.editPost;
     
    const MyDocumentSettingTest = () => (
            <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel">
            <p>My Document Setting Panel</p>
        </PluginDocumentSettingPanel>
    );
     
     registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
    

    The PluginPostPublishPanel has a property initialOpen that can be set to true but that isn’t available/working for PluginDocumentSettingPanel.

    Is there still a way to achieve the same for a PluginPostPublishPanel plugin?

Viewing 1 replies (of 1 total)
  • Plugin Author Jorge Costa

    (@jorgefilipecosta)

    Hi @benny,

    You may programmatically open the panel by using:
    wp.data.dispatch( ‘core/edit-post’ ).toggleEditorPanelOpened( panelName ).
    The block editor persists what panels the user opened and closed, so ideally that code should only be executed one time. I guess one way to accomplish this is checking that wp.data.selelect.getPreference( ‘panels’ )[ panelName ] is undefined before executing the action.

    I hope you find my answer useful, feel free to comment if you need additional clarification.

Viewing 1 replies (of 1 total)
  • The topic ‘How to have a PluginDocumentSettingPanel initially opened?’ is closed to new replies.