initial open/toggle PluginDocumentSettingPanel panel in document setting block editor gutenberg

i want make new panel inside document setting tab with React Script from this documentation

but the problem panel not toggle onload/initial i have try open with

dispatch('core/edit-post').toggleEditorPanelOpened('mycustom-panel')

but dont work,i see my custom panel not store in

select( 'core/edit-post' ).getPreference('panels')

so cant toggle it with toggleEditorPanelOpened

this my code to register PluginDocumentSettingPanel

const { registerPlugin } = wp.plugins;
const { PluginDocumentSettingPanel } = wp.editPost;

const PluginDocumentSettingPanelDemo = () => (
    <PluginDocumentSettingPanel
        name="mycustom-panel"
        title="Tips"
        className="mycustom-panel"
    >
        this is tips to write better content
    </PluginDocumentSettingPanel>
);
registerPlugin( 'plugin-document-setting-panel-mycustom', { render: PluginDocumentSettingPanelDemo, icon: null } );

1 Answer
1

This is a known issue in Gutenberg.

You can get this working by passing {plugin-slug}/{panel-name}

For your example, try:

dispatch('core/edit-post').toggleEditorPanelOpened('plugin-document-setting-panel-mycustom/mycustom-panel')

Leave a Comment