Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Editor: Deprecate the as prop of the plugin menu item components
  • Loading branch information
Mamaduka committed Sep 2, 2026
commit e0025158581bd3a7680539f7f6332b4a7bf63a72
6 changes: 5 additions & 1 deletion packages/editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

### Breaking Changes

- `PluginMoreMenuItem`, `PluginSidebarMoreMenuItem`: Items render with the `Menu` component of `@wordpress/ui` instead of `MenuItem`. A link item honors only `target="_blank"`, and a custom `as` has to forward its ref ([#81564](https://github.com/WordPress/gutenberg/pull/81564)).
- `PluginMoreMenuItem`, `PluginSidebarMoreMenuItem`: Items render with the `Menu` component of `@wordpress/ui` instead of `MenuItem`. A link item honors only `target="_blank"` ([#81564](https://github.com/WordPress/gutenberg/pull/81564)).

### Deprecations

- `PluginMoreMenuItem`, `PluginSidebarMoreMenuItem`, `PluginPreviewMenuItem`: Deprecate the `as` prop. It was never a documented part of these components, and the menu now renders the item itself. The prop is ignored ([#82319](https://github.com/WordPress/gutenberg/pull/82319)).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs still say that all extra props are forwarded, so "was never documented" is not 100% accurate.

We should probably update the JSDoc and generated README to say that as is ignored.

Potentially even add a short dev note?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can combine Menu migration dev notes that affect consumers in a single post.


### Bug Fixes

Expand Down
17 changes: 15 additions & 2 deletions packages/editor/src/components/plugin-more-menu-item/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import deprecated from '@wordpress/deprecated';
import { usePluginContext } from '@wordpress/plugins';
import { ActionItem } from '@wordpress/interface';

Expand Down Expand Up @@ -60,11 +61,23 @@ import { ActionItem } from '@wordpress/interface';
*/
export default function PluginMoreMenuItem( props ) {
const context = usePluginContext();
// `as` was never part of the contract. It is dropped so that it does not
// reach the item the menu renders.
const { as, ...itemProps } = props;

if ( as ) {
deprecated( 'The `as` prop of wp.editor.PluginMoreMenuItem', {
since: '7.2',
version: '7.4',
hint: 'The menu renders the item itself.',
} );
Comment on lines +69 to +72

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This drops as immediately, but version: '7.4' makes the warning say it will be removed in 7.4. Could we follow the useResizeCanvas precedent from #75121 instead: omit version and say that the prop is already ignored?

Here and everywhere else in the PR where we call deprecated() ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Even with versions specified, we never actually remove things. It's just an extra nudge for updating.

}

return (
<ActionItem
name="core/plugin-more-menu"
icon={ props.icon || context.icon }
{ ...props }
icon={ itemProps.icon || context.icon }
{ ...itemProps }
/>
);
}
17 changes: 15 additions & 2 deletions packages/editor/src/components/plugin-preview-menu-item/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import deprecated from '@wordpress/deprecated';
import { usePluginContext } from '@wordpress/plugins';
import { ActionItem } from '@wordpress/interface';

Expand Down Expand Up @@ -39,11 +40,23 @@ import { ActionItem } from '@wordpress/interface';
*/
export default function PluginPreviewMenuItem( props ) {
const context = usePluginContext();
// `as` was never part of the contract. It is dropped so that it does not
// reach the item the menu renders.
const { as, ...itemProps } = props;

if ( as ) {
deprecated( 'The `as` prop of wp.editor.PluginPreviewMenuItem', {
since: '7.2',
version: '7.4',
hint: 'The menu renders the item itself.',
} );
}

return (
<ActionItem
name="core/plugin-preview-menu"
icon={ props.icon || context.icon }
{ ...props }
icon={ itemProps.icon || context.icon }
{ ...itemProps }
/>
);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import deprecated from '@wordpress/deprecated';
import { ComplementaryAreaMoreMenuItem } from '@wordpress/interface';

/**
Expand Down Expand Up @@ -49,5 +50,17 @@ import { ComplementaryAreaMoreMenuItem } from '@wordpress/interface';
* @return {React.ReactNode} The rendered component.
*/
export default function PluginSidebarMoreMenuItem( props ) {
return <ComplementaryAreaMoreMenuItem scope="core" { ...props } />;
// `as` was never part of the contract. It is dropped so that it does not
// reach the item the menu renders.
const { as, ...itemProps } = props;

if ( as ) {
deprecated( 'The `as` prop of wp.editor.PluginSidebarMoreMenuItem', {
since: '7.2',
version: '7.4',
hint: 'The menu renders the item itself.',
} );
}

return <ComplementaryAreaMoreMenuItem scope="core" { ...itemProps } />;
}
Loading