diff --git a/packages/block-library/src/utils/clean-empty-object.js b/packages/block-library/src/utils/clean-empty-object.js index 39e67a7657f331..e0e55c659bf575 100644 --- a/packages/block-library/src/utils/clean-empty-object.js +++ b/packages/block-library/src/utils/clean-empty-object.js @@ -18,9 +18,9 @@ const cleanEmptyObject = ( object ) => { return object; } const cleanedNestedObjects = Object.fromEntries( - Object.entries( object ).filter( ( [ , value ] ) => - Boolean( cleanEmptyObject( value ) ) - ) + Object.entries( object ) + .map( ( [ key, value ] ) => [ key, cleanEmptyObject( value ) ] ) + .filter( ( [ , value ] ) => Boolean( value ) ) ); return isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects; };