Skip to content

Allow plugins to unset the default icon from PluginPrePublishPanel #69045

@afercia

Description

@afercia

Description

Splitting this out from #68688

PluginPrePublishPanel adds a panel to the pre-publish sidebar. It can be used 'standalone', for example directly in the editor somewhere, or in a registered plugin.

It is part of the editor package so that to my understanding using it 'standalone' directly in the editor is allowed.

When used 'standalone' and no icon prop is passed, it doesn't render an icon.
Instead, when used in a registered plugin, it either shows the passed icon or the fallback plugin icon that comes from usePluginContext. This is intentional to make it 'inherit' the icon a plugin may use in its registerPlugin() call. This way, the panel will use the same icon that it is shown in the 'pinned' plugin icon in the editor top bar.

Plugins can pass a different icon for the sidebar panel. However, the cannot unset the icon shown in the sidebar panel. It will fallback to the generic 'plugin' icon.

There may be cases where a plugin may want to show an icon for the 'pinned' button in the top bar but may not want to show an icon in the sidebar panel. It seems to me the current implementation assumes there should always be an icon, which isn't necessarily what plugins want.

There are workarounds e.g. passing an empty fragment icon={ <></> } but that's not great. I'd tend to think there should be a way for plugins to unset the icon of the sidebar panel.

It is worth nothing that the editor itself resigters some plugins e.g.

Step-by-step reproduction instructions

Register a simple plugin for hte pre-publish panel somewhere in the code e.g.

import { registerPlugin } from '@wordpress/plugins';
import { PluginPrePublishPanel } from '@wordpress/editor';

registerPlugin( 'my-test-plugin-panel', {
	render() {
		return (
			<PluginPrePublishPanel
				className="my-plugin-pre-publish-panel"
				title="My plugin panel title"
				initialOpen
			>
				My plugin panel content
			</PluginPrePublishPanel>
		);
	},
} );
  • Edit a post and click Publish to make the pre-publish sidebar appear.
  • Observe the panel added by your plugin shows a default icon. Screenshot:

Image

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Package] Editor/packages/editor[Type] BugAn existing feature does not function as intended

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions