Skip to content

Commit ba514ab

Browse files
fix (migration): do not re-migrate text gradient color if it's already migrated before
1 parent 8d9cbdf commit ba514ab

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/block-components/typography/deprecated.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ export const deprecateTypographyGradientColor = {
5858
if ( getAttribute( 'textColorType' ) === 'gradient' && getAttribute( 'textColor2' ) ) {
5959
const textColor1 = getAttribute( 'textColor1' ) || getAttribute( 'textColor2' )
6060
const textColor2 = getAttribute( 'textColor2' ) || getAttribute( 'textColor1' )
61-
const textGradientDirection = getAttribute( 'textGradientDirection' ) || getAttribute( 'textGradientDirection' ) === 0 ? getAttribute( 'textGradientDirection' ) : 180
62-
newAttributes[ getAttrName( 'textColor1' ) ] = `linear-gradient(${ textGradientDirection }deg, ${ textColor1 } 0%, ${ textColor2 } 100%)`
61+
62+
const isTextColor1Gradient = textColor1 && textColor1.includes( '-gradient' )
63+
const isTextColor2Gradient = textColor2 && textColor2.includes( '-gradient' )
64+
65+
if ( ! isTextColor1Gradient && ! isTextColor2Gradient ) {
66+
const textGradientDirection = getAttribute( 'textGradientDirection' ) || getAttribute( 'textGradientDirection' ) === 0 ? getAttribute( 'textGradientDirection' ) : 180
67+
newAttributes[ getAttrName( 'textColor1' ) ] = `linear-gradient(${ textGradientDirection }deg, ${ textColor1 } 0%, ${ textColor2 } 100%)`
68+
}
6369
}
6470

6571
return newAttributes

0 commit comments

Comments
 (0)