Skip to content

Commit 24f14de

Browse files
more logic so that backgroundColor style does not get erased when setting text-color in UE
1 parent 7ac23c9 commit 24f14de

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

blocks/columns/columns.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,23 @@ export default function decorate(block) {
77
console.log('bkgdColorAttr in columns-container class: ', bkgdColorAttr);
88

99
if (bkgdColorAttr) block.style.backgroundColor = bkgdColorAttr;
10+
const currentBkgdColor = block.style.backgroundColor;
1011
if (textColorAttr) block.style.color = textColorAttr;
1112

1213
// for UE as value needs to be saved in different element due to having to walk the DOM tree to set the values
1314
const columnsChild = block.querySelector('div');
1415
const ueBkgdColorAttr = columnsChild?.getAttribute('data-background-color');
15-
console.log('6 bkgdColorAttr in columns row UE: ', ueBkgdColorAttr);
16+
console.log('7 bkgdColorAttr in columns row UE: ', ueBkgdColorAttr);
1617

1718
const ueTextColorAttr = columnsChild?.getAttribute('data-text-color');
18-
console.log('6 textColorAttr in columns row UE: ', ueTextColorAttr);
19+
console.log('7 textColorAttr in columns row UE: ', ueTextColorAttr);
1920

20-
if (ueBkgdColorAttr && ueBkgdColorAttr != null && (!block.style.backgroundColor || block.style.backgroundColor != 'white')) block.style.backgroundColor = ueBkgdColorAttr;
21-
console.log('6 block.style.backgroundColor: ', block.style.backgroundColor);
21+
if (ueBkgdColorAttr && ueBkgdColorAttr != null && (!block.style.backgroundColor || block.style.backgroundColor == 'white')) {
22+
block.style.backgroundColor = ueBkgdColorAttr;
23+
} else {
24+
block.style.backgroundColor = currentBkgdColor;
25+
}
26+
console.log('7 block.style.backgroundColor: ', block.style.backgroundColor);
2227
if (ueTextColorAttr && ueTextColorAttr != null && !block.style.color) block.style.color = ueTextColorAttr;
2328

2429
const cols = [...block.firstElementChild.children];

0 commit comments

Comments
 (0)