diff --git a/packages/block-editor/src/components/color-palette/with-color-context.js b/packages/block-editor/src/components/color-palette/with-color-context.js index 85bff66fa23d3a..4c60a44b9348ea 100644 --- a/packages/block-editor/src/components/color-palette/with-color-context.js +++ b/packages/block-editor/src/components/color-palette/with-color-context.js @@ -1,8 +1,3 @@ -/** - * External dependencies - */ -import { isEmpty } from 'lodash'; - /** * WordPress dependencies */ @@ -23,7 +18,8 @@ export default createHigherOrderComponent( ( WrappedComponent ) => { props.disableCustomColors === undefined ? disableCustomColorsFeature : props.disableCustomColors; - const hasColorsToChoose = ! isEmpty( colors ) || ! disableCustomColors; + const hasColorsToChoose = + ( colors && colors.length > 0 ) || ! disableCustomColors; return ( 0 ) || ! disableCustomColors ); const canChooseAGradient = onGradientChange && - ( ! isEmpty( gradients ) || ! disableCustomGradients ); + ( ( gradients && gradients.length > 0 ) || ! disableCustomGradients ); if ( ! canChooseAColor && ! canChooseAGradient ) { return null; diff --git a/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.js b/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.js index a5bab5a3ca986c..1ee60a5ccc6040 100644 --- a/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.js +++ b/packages/block-editor/src/components/colors-gradients/panel-color-gradient-settings.js @@ -2,7 +2,6 @@ * External dependencies */ import classnames from 'classnames'; -import { isEmpty } from 'lodash'; /** * WordPress dependencies @@ -43,14 +42,14 @@ export const PanelColorGradientSettingsInner = ( { const panelId = useInstanceId( PanelColorGradientSettingsInner ); const { batch } = useRegistry(); if ( - isEmpty( colors ) && - isEmpty( gradients ) && + ( ! colors || colors.length === 0 ) && + ( ! gradients || gradients.length === 0 ) && disableCustomColors && disableCustomGradients && settings?.every( ( setting ) => - isEmpty( setting.colors ) && - isEmpty( setting.gradients ) && + ( ! setting.colors || setting.colors.length === 0 ) && + ( ! setting.gradients || setting.gradients.length === 0 ) && ( setting.disableCustomColors === undefined || setting.disableCustomColors ) && ( setting.disableCustomGradients === undefined || diff --git a/packages/block-editor/src/components/global-styles/get-block-css-selector.js b/packages/block-editor/src/components/global-styles/get-block-css-selector.js index 79a736e1b6978c..3b2b277c422a48 100644 --- a/packages/block-editor/src/components/global-styles/get-block-css-selector.js +++ b/packages/block-editor/src/components/global-styles/get-block-css-selector.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { get, isEmpty } from 'lodash'; +import { get } from 'lodash'; /** * Internal dependencies @@ -31,7 +31,7 @@ export function getBlockCSSSelector( const { fallback = false } = options; const { name, selectors, supports } = blockType; - const hasSelectors = ! isEmpty( selectors ); + const hasSelectors = selectors && Object.keys( selectors ).length > 0; const path = Array.isArray( target ) ? target.join( '.' ) : target; // Root selector. diff --git a/packages/block-editor/src/components/global-styles/use-global-styles-output.js b/packages/block-editor/src/components/global-styles/use-global-styles-output.js index d496041627d070..0b82c40f6803fd 100644 --- a/packages/block-editor/src/components/global-styles/use-global-styles-output.js +++ b/packages/block-editor/src/components/global-styles/use-global-styles-output.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { get, isEmpty, kebabCase, set } from 'lodash'; +import { get, kebabCase, set } from 'lodash'; /** * WordPress dependencies @@ -697,7 +697,7 @@ export const getNodesWithSettings = ( tree, blockSelectors ) => { // Top-level. const presets = pickPresets( tree.settings ); const custom = tree.settings?.custom; - if ( ! isEmpty( presets ) || custom ) { + if ( Object.keys( presets ).length > 0 || custom ) { nodes.push( { presets, custom, @@ -710,7 +710,7 @@ export const getNodesWithSettings = ( tree, blockSelectors ) => { ( [ blockName, node ] ) => { const blockPresets = pickPresets( node ); const blockCustom = node.custom; - if ( ! isEmpty( blockPresets ) || blockCustom ) { + if ( Object.keys( blockPresets ).length > 0 || blockCustom ) { nodes.push( { presets: blockPresets, custom: blockCustom, @@ -976,7 +976,7 @@ export const toStyles = ( } const classes = getPresetsClasses( selector, presets ); - if ( ! isEmpty( classes ) ) { + if ( classes.length > 0 ) { ruleset += classes; } } ); @@ -992,7 +992,10 @@ export function toSvgFilters( tree, blockSelectors ) { } const getSelectorsConfig = ( blockType, rootSelector ) => { - if ( ! isEmpty( blockType?.selectors ) ) { + if ( + blockType?.selectors && + Object.keys( blockType.selectors ).length > 0 + ) { return blockType.selectors; }