Skip to content

Commit

Permalink
Block Editor: Remove 'React.Children' legacy API in 'Warning' compone…
Browse files Browse the repository at this point in the history
…nt (#67675)


Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent b8bfb4d commit 886662e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions packages/block-editor/src/components/warning/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import clsx from 'clsx';
/**
* WordPress dependencies
*/
import { Children } from '@wordpress/element';
import { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { moreVertical } from '@wordpress/icons';
Expand All @@ -20,10 +19,10 @@ function Warning( { className, actions, children, secondaryActions } ) {
{ children }
</p>

{ ( Children.count( actions ) > 0 || secondaryActions ) && (
{ ( actions?.length > 0 || secondaryActions ) && (
<div className="block-editor-warning__actions">
{ Children.count( actions ) > 0 &&
Children.map( actions, ( action, i ) => (
{ actions?.length > 0 &&
actions.map( ( action, i ) => (
<span
key={ i }
className="block-editor-warning__action"
Expand Down
4 changes: 3 additions & 1 deletion packages/block-editor/src/components/warning/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ describe( 'Warning', () => {

it( 'should show primary actions', () => {
render(
<Warning actions={ <button>Click me</button> }>Message</Warning>
<Warning actions={ [ <button key="test">Click me</button> ] }>
Message
</Warning>
);

expect(
Expand Down

1 comment on commit 886662e

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 886662e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12196737623
📝 Reported issues:

Please sign in to comment.