Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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, which reached the item only because these components forward every extra prop. The menu now renders the item itself, so the prop is ignored ([#82319](https://github.com/WordPress/gutenberg/pull/82319)).

### Bug Fixes

Expand Down
4 changes: 2 additions & 2 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ _Parameters_
- _props.href_ `[string]`: When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
- _props.icon_ `[WPBlockTypeIconRender]`: The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
- _props.onClick_ `[Function]`: The callback function to be executed when the user clicks the menu item.
- _props.other_ `[...*]`: Any additional props are passed through to the underlying menu item component.
- _props.other_ `[...*]`: Any additional props are passed through to the underlying menu item component, except for `as`, which is deprecated and ignored.

_Returns_

Expand Down Expand Up @@ -861,7 +861,7 @@ _Parameters_
- _props.href_ `[string]`: When `href` is provided, the menu item is rendered as an anchor instead of a button. It corresponds to the `href` attribute of the anchor.
- _props.icon_ `[WPBlockTypeIconRender]`: The icon to be rendered to the left of the menu item label. Can be a Dashicon slug or an SVG WP element.
- _props.onClick_ `[Function]`: The callback function to be executed when the user clicks the menu item.
- _props.other_ `[...*]`: Any additional props are passed through to the underlying MenuItem component.
- _props.other_ `[...*]`: Any additional props are passed through to the underlying menu item component, except for `as`, which is deprecated and ignored.

_Returns_

Expand Down
18 changes: 15 additions & 3 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 All @@ -10,7 +11,7 @@ import { ActionItem } from '@wordpress/interface';
* @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
* @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
* @param {...*} [props.other] Any additional props are passed through to the underlying menu item component.
* @param {...*} [props.other] Any additional props are passed through to the underlying menu item component, except for `as`, which is deprecated and ignored.
*
* @example
* ```js
Expand Down Expand Up @@ -60,11 +61,22 @@ import { ActionItem } from '@wordpress/interface';
*/
export default function PluginMoreMenuItem( props ) {
const context = usePluginContext();
// The menu renders the item itself, so `as` is dropped rather than
// forwarded.
const { as, ...itemProps } = props;

if ( as ) {
deprecated( 'The `as` prop of wp.editor.PluginMoreMenuItem', {
since: '7.2',
hint: 'The menu renders the item itself. The prop is ignored.',
} );
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 }
/>
);
}
18 changes: 15 additions & 3 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 All @@ -10,7 +11,7 @@ import { ActionItem } from '@wordpress/interface';
* @param {string} [props.href] When `href` is provided, the menu item is rendered as an anchor instead of a button. It corresponds to the `href` attribute of the anchor.
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The icon to be rendered to the left of the menu item label. Can be a Dashicon slug or an SVG WP element.
* @param {Function} [props.onClick] The callback function to be executed when the user clicks the menu item.
* @param {...*} [props.other] Any additional props are passed through to the underlying MenuItem component.
* @param {...*} [props.other] Any additional props are passed through to the underlying menu item component, except for `as`, which is deprecated and ignored.
*
* @example
* ```jsx
Expand Down Expand Up @@ -39,11 +40,22 @@ import { ActionItem } from '@wordpress/interface';
*/
export default function PluginPreviewMenuItem( props ) {
const context = usePluginContext();
// The menu renders the item itself, so `as` is dropped rather than
// forwarded.
const { as, ...itemProps } = props;

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

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,16 @@ import { ComplementaryAreaMoreMenuItem } from '@wordpress/interface';
* @return {React.ReactNode} The rendered component.
*/
export default function PluginSidebarMoreMenuItem( props ) {
return <ComplementaryAreaMoreMenuItem scope="core" { ...props } />;
// The menu renders the item itself, so `as` is dropped rather than
// forwarded.
const { as, ...itemProps } = props;

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

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