Skip to content

Commit

Permalink
Remove content pattern property if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
SantosGuillamot committed May 9, 2024
1 parent e2a1b8a commit 9d444a3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/patterns/src/components/reset-overrides-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ export default function ResetOverridesControl( props ) {
return {
isOverriden: !! existingOverrides?.[ name ],
resetOverrides: async () => {
// If all overrides are undefined, reset the whole content attribute.
const newObject = existingOverrides.hasOwnProperty( name )
? undefined
: { ...existingOverrides, [ name ]: undefined };
updateBlockAttributes( patternClientId, {
[ CONTENT ]: {
...existingOverrides,
[ name ]: undefined,
},
[ CONTENT ]: newObject,
} );
},
};
Expand Down

0 comments on commit 9d444a3

Please sign in to comment.