From a018537b2a3f5d7e380b1b562196e0583e8f0ef3 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Fri, 6 Dec 2024 13:05:49 +0400 Subject: [PATCH 1/2] Block Editor: Remove 'React.Children' legacy API in 'Warning' component --- packages/block-editor/src/components/warning/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/components/warning/index.js b/packages/block-editor/src/components/warning/index.js index 8b6279bef6044d..17a014107b43af 100644 --- a/packages/block-editor/src/components/warning/index.js +++ b/packages/block-editor/src/components/warning/index.js @@ -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'; @@ -20,10 +19,10 @@ function Warning( { className, actions, children, secondaryActions } ) { { children }

- { ( Children.count( actions ) > 0 || secondaryActions ) && ( + { ( actions?.length > 0 || secondaryActions ) && (
- { Children.count( actions ) > 0 && - Children.map( actions, ( action, i ) => ( + { actions?.length > 0 && + actions.map( ( action, i ) => ( Date: Fri, 6 Dec 2024 13:19:12 +0400 Subject: [PATCH 2/2] Update unit test --- packages/block-editor/src/components/warning/test/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/warning/test/index.js b/packages/block-editor/src/components/warning/test/index.js index 6a0373da611c01..bdb910f68c16e0 100644 --- a/packages/block-editor/src/components/warning/test/index.js +++ b/packages/block-editor/src/components/warning/test/index.js @@ -18,7 +18,9 @@ describe( 'Warning', () => { it( 'should show primary actions', () => { render( - Click me }>Message + Click me ] }> + Message + ); expect(