diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index bbc4625a45367..d6cf16d4d5e81 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -17,6 +17,9 @@ - `ScrollLock`: Convert to TypeScript ([#42303](https://github.com/WordPress/gutenberg/pull/42303)). - `TreeSelect`: Refactor away from `_.compact()` ([#42438](https://github.com/WordPress/gutenberg/pull/42438)). - `MediaEdit`: Refactor away from `_.compact()` for mobile ([#42438](https://github.com/WordPress/gutenberg/pull/42438)). +- `BoxControl`: Refactor away from `_.isEmpty()` ([#42468](https://github.com/WordPress/gutenberg/pull/42468)). +- `RadioControl`: Refactor away from `_.isEmpty()` ([#42468](https://github.com/WordPress/gutenberg/pull/42468)). +- `SelectControl`: Refactor away from `_.isEmpty()` ([#42468](https://github.com/WordPress/gutenberg/pull/42468)). ## 19.15.0 (2022-07-13) diff --git a/packages/components/src/box-control/utils.js b/packages/components/src/box-control/utils.js index 689df3d67d985..248f5bc48b621 100644 --- a/packages/components/src/box-control/utils.js +++ b/packages/components/src/box-control/utils.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { isEmpty } from 'lodash'; - /** * WordPress dependencies */ @@ -145,14 +140,12 @@ export function isValuesMixed( values = {}, selectedUnits, sides = ALL_SIDES ) { export function isValuesDefined( values ) { return ( values !== undefined && - ! isEmpty( - Object.values( values ).filter( - // Switching units when input is empty causes values only - // containing units. This gives false positive on mixed values - // unless filtered. - ( value ) => !! value && /\d/.test( value ) - ) - ) + Object.values( values ).filter( + // Switching units when input is empty causes values only + // containing units. This gives false positive on mixed values + // unless filtered. + ( value ) => !! value && /\d/.test( value ) + ).length > 0 ); } diff --git a/packages/components/src/radio-control/index.tsx b/packages/components/src/radio-control/index.tsx index 5a4ffe874dacf..6b4c1df8d30e0 100644 --- a/packages/components/src/radio-control/index.tsx +++ b/packages/components/src/radio-control/index.tsx @@ -1,7 +1,6 @@ /** * External dependencies */ -import { isEmpty } from 'lodash'; import classnames from 'classnames'; import type { ChangeEvent } from 'react'; @@ -65,7 +64,7 @@ export function RadioControl( const onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) => onChange( event.target.value ); - if ( isEmpty( options ) ) { + if ( ! options?.length ) { return null; } diff --git a/packages/components/src/select-control/index.tsx b/packages/components/src/select-control/index.tsx index 3b43b66651b27..252230baefa9a 100644 --- a/packages/components/src/select-control/index.tsx +++ b/packages/components/src/select-control/index.tsx @@ -1,7 +1,6 @@ /** * External dependencies */ -import { isEmpty } from 'lodash'; import classNames from 'classnames'; import type { ChangeEvent, FocusEvent, ForwardedRef } from 'react'; @@ -59,7 +58,7 @@ function UnforwardedSelectControl( const helpId = help ? `${ id }__help` : undefined; // Disable reason: A select with an onchange throws a warning. - if ( isEmpty( options ) && ! children ) return null; + if ( ! options?.length && ! children ) return null; const handleOnBlur = ( event: FocusEvent< HTMLSelectElement > ) => { onBlur( event );