diff --git a/packages/edit-site/src/components/global-styles/shadows-edit-panel.js b/packages/edit-site/src/components/global-styles/shadows-edit-panel.js index af5f3445a5119..7321e927fbbae 100644 --- a/packages/edit-site/src/components/global-styles/shadows-edit-panel.js +++ b/packages/edit-site/src/components/global-styles/shadows-edit-panel.js @@ -301,18 +301,17 @@ function ShadowEditor( { shadow, onChange } ) { const shadowParts = useMemo( () => getShadowParts( shadow ), [ shadow ] ); const onChangeShadowPart = ( index, part ) => { - shadowParts[ index ] = part; - onChange( shadowParts.join( ', ' ) ); + const newShadowParts = [ ...shadowParts ]; + newShadowParts[ index ] = part; + onChange( newShadowParts.join( ', ' ) ); }; const onAddShadowPart = () => { - shadowParts.push( defaultShadow ); - onChange( shadowParts.join( ', ' ) ); + onChange( [ ...shadowParts, defaultShadow ].join( ', ' ) ); }; const onRemoveShadowPart = ( index ) => { - shadowParts.splice( index, 1 ); - onChange( shadowParts.join( ', ' ) ); + onChange( shadowParts.filter( ( p, i ) => i !== index ).join( ', ' ) ); }; return (