From 7c988d6ad37d018f845bffa3f5fa6d461309515e Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Wed, 21 Jul 2021 17:25:34 +1000 Subject: [PATCH] Clean new style objects after resetting spacing values --- packages/block-editor/src/hooks/margin.js | 6 +++--- packages/block-editor/src/hooks/padding.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/block-editor/src/hooks/margin.js b/packages/block-editor/src/hooks/margin.js index b734191a35b12..6a264d0d4d0e3 100644 --- a/packages/block-editor/src/hooks/margin.js +++ b/packages/block-editor/src/hooks/margin.js @@ -31,7 +31,7 @@ export function hasMarginSupport( blockType ) { /** * Checks if there is a current value in the margin block support attributes. * - * @param {Object} props Block props. + * @param {Object} props Block props. * @return {boolean} Whether or not the block has a margin value set. */ export function hasMarginValue( props ) { @@ -50,13 +50,13 @@ export function resetMargin( { attributes = {}, setAttributes } ) { const { style } = attributes; setAttributes( { - style: { + style: cleanEmptyObject( { ...style, spacing: { ...style?.spacing, margin: undefined, }, - }, + } ), } ); } diff --git a/packages/block-editor/src/hooks/padding.js b/packages/block-editor/src/hooks/padding.js index c8392f04ec7b7..9e881f4423300 100644 --- a/packages/block-editor/src/hooks/padding.js +++ b/packages/block-editor/src/hooks/padding.js @@ -31,7 +31,7 @@ export function hasPaddingSupport( blockType ) { /** * Checks if there is a current value in the padding block support attributes. * - * @param {Object} props Block props. + * @param {Object} props Block props. * @return {boolean} Whether or not the block has a padding value set. */ export function hasPaddingValue( props ) { @@ -50,13 +50,13 @@ export function resetPadding( { attributes = {}, setAttributes } ) { const { style } = attributes; setAttributes( { - style: { + style: cleanEmptyObject( { ...style, spacing: { ...style?.spacing, padding: undefined, }, - }, + } ), } ); }