Skip to content

Commit 75ba2df

Browse files
committed
fix #850
1 parent a0c99a0 commit 75ba2df

File tree

5 files changed

+119
-19
lines changed

5 files changed

+119
-19
lines changed

Diff for: src/blocks/section-break-the-grid/edit.js

+26-3
Original file line numberDiff line numberDiff line change
@@ -1393,12 +1393,35 @@ export default function ( {
13931393
{
13941394
positionValue: backgroundText.position,
13951395
onPositionChange: ( value ) => {
1396-
newBackgroundText.position = value;
1396+
newBackgroundText.position.top =
1397+
null != value?.top
1398+
? value?.top.match( /^\d+$/ )
1399+
? `${ value?.top }px`
1400+
: value?.top
1401+
: undefined;
1402+
newBackgroundText.position.right =
1403+
null != value?.right
1404+
? value?.right.match( /^\d+$/ )
1405+
? `${ value?.right }px`
1406+
: value?.right
1407+
: undefined;
1408+
newBackgroundText.position.bottom =
1409+
null != value?.bottom
1410+
? value?.bottom.match( /^\d+$/ )
1411+
? `${ value?.bottom }px`
1412+
: value?.bottom
1413+
: undefined;
1414+
newBackgroundText.position.left =
1415+
null != value?.left
1416+
? value?.left.match( /^\d+$/ )
1417+
? `${ value?.left }px`
1418+
: value?.left
1419+
: undefined;
13971420

13981421
setAttributes( {
1399-
backgroundText: {
1422+
backgroundText: cleanEmptyObject( {
14001423
...newBackgroundText,
1401-
},
1424+
} ),
14021425
} );
14031426
},
14041427
defaultValue:

Diff for: src/blocks/section-with-bgimage/edit.js

+26-3
Original file line numberDiff line numberDiff line change
@@ -1177,12 +1177,35 @@ export default function ( {
11771177
{
11781178
positionValue: backgroundText.position,
11791179
onPositionChange: ( value ) => {
1180-
newBackgroundText.position = value;
1180+
newBackgroundText.position.top =
1181+
null != value?.top
1182+
? value?.top.match( /^\d+$/ )
1183+
? `${ value?.top }px`
1184+
: value?.top
1185+
: undefined;
1186+
newBackgroundText.position.right =
1187+
null != value?.right
1188+
? value?.right.match( /^\d+$/ )
1189+
? `${ value?.right }px`
1190+
: value?.right
1191+
: undefined;
1192+
newBackgroundText.position.bottom =
1193+
null != value?.bottom
1194+
? value?.bottom.match( /^\d+$/ )
1195+
? `${ value?.bottom }px`
1196+
: value?.bottom
1197+
: undefined;
1198+
newBackgroundText.position.left =
1199+
null != value?.left
1200+
? value?.left.match( /^\d+$/ )
1201+
? `${ value?.left }px`
1202+
: value?.left
1203+
: undefined;
11811204

11821205
setAttributes( {
1183-
backgroundText: {
1206+
backgroundText: cleanEmptyObject( {
11841207
...newBackgroundText,
1185-
},
1208+
} ),
11861209
} );
11871210
},
11881211
defaultValue:

Diff for: src/blocks/section-with-bgvideo/edit.js

+26-3
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,35 @@ export default function ( {
509509
{
510510
positionValue: backgroundText.position,
511511
onPositionChange: ( value ) => {
512-
newBackgroundText.position = value;
512+
newBackgroundText.position.top =
513+
null != value?.top
514+
? value?.top.match( /^\d+$/ )
515+
? `${ value?.top }px`
516+
: value?.top
517+
: undefined;
518+
newBackgroundText.position.right =
519+
null != value?.right
520+
? value?.right.match( /^\d+$/ )
521+
? `${ value?.right }px`
522+
: value?.right
523+
: undefined;
524+
newBackgroundText.position.bottom =
525+
null != value?.bottom
526+
? value?.bottom.match( /^\d+$/ )
527+
? `${ value?.bottom }px`
528+
: value?.bottom
529+
: undefined;
530+
newBackgroundText.position.left =
531+
null != value?.left
532+
? value?.left.match( /^\d+$/ )
533+
? `${ value?.left }px`
534+
: value?.left
535+
: undefined;
513536

514537
setAttributes( {
515-
backgroundText: {
538+
backgroundText: cleanEmptyObject( {
516539
...newBackgroundText,
517-
},
540+
} ),
518541
} );
519542
},
520543
defaultValue:

Diff for: src/blocks/section/components/background.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -1099,19 +1099,27 @@ export const generateStylesForSectionBackground = ( {
10991099
: undefined;
11001100
styles[ '--smb-section--background-text-top' ] = !! backgroundText
11011101
?.position?.top
1102-
? backgroundText.position.top
1102+
? backgroundText.position.top.match( /^\d+$/ )
1103+
? `${ backgroundText.position.top }px`
1104+
: backgroundText.position.top
11031105
: undefined;
11041106
styles[ '--smb-section--background-text-right' ] = !! backgroundText
11051107
?.position?.right
1106-
? backgroundText.position.right
1108+
? backgroundText.position.right.match( /^\d+$/ )
1109+
? `${ backgroundText.position.right }px`
1110+
: backgroundText.position.right
11071111
: undefined;
11081112
styles[ '--smb-section--background-text-bottom' ] = !! backgroundText
11091113
?.position?.bottom
1110-
? backgroundText.position.bottom
1114+
? backgroundText.position.bottom.match( /^\d+$/ )
1115+
? `${ backgroundText.position.bottom }px`
1116+
: backgroundText.position.bottom
11111117
: undefined;
11121118
styles[ '--smb-section--background-text-left' ] = !! backgroundText
11131119
?.position?.left
1114-
? backgroundText.position.left
1120+
? backgroundText.position.left.match( /^\d+$/ )
1121+
? `${ backgroundText.position.left }px`
1122+
: backgroundText.position.left
11151123
: undefined;
11161124
}
11171125

Diff for: src/blocks/section/edit.js

+29-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
import { useSelect } from '@wordpress/data';
1818
import { __ } from '@wordpress/i18n';
1919

20-
import { toNumber } from '@smb/helper';
20+
import { toNumber, cleanEmptyObject } from '@smb/helper';
2121

2222
import { PanelBasicSettings } from './components/basic';
2323
import { Edit as Header } from './components/header';
@@ -533,12 +533,35 @@ export default function ( {
533533
{
534534
positionValue: backgroundText.position,
535535
onPositionChange: ( value ) => {
536-
newBackgroundText.position = value;
537-
538-
setAttributes( {
539-
backgroundText: {
536+
newBackgroundText.position.top =
537+
null != value?.top
538+
? value?.top.match( /^\d+$/ )
539+
? `${ value?.top }px`
540+
: value?.top
541+
: undefined;
542+
newBackgroundText.position.right =
543+
null != value?.right
544+
? value?.right.match( /^\d+$/ )
545+
? `${ value?.right }px`
546+
: value?.right
547+
: undefined;
548+
newBackgroundText.position.bottom =
549+
null != value?.bottom
550+
? value?.bottom.match( /^\d+$/ )
551+
? `${ value?.bottom }px`
552+
: value?.bottom
553+
: undefined;
554+
newBackgroundText.position.left =
555+
null != value?.left
556+
? value?.left.match( /^\d+$/ )
557+
? `${ value?.left }px`
558+
: value?.left
559+
: undefined;
560+
561+
setAttributes( {
562+
backgroundText: cleanEmptyObject( {
540563
...newBackgroundText,
541-
},
564+
} ),
542565
} );
543566
},
544567
defaultValue:

0 commit comments

Comments
 (0)