Skip to content

Commit f6aebf5

Browse files
committed
fix: custom style would sometimes fail when editing new widgets
1 parent f8e31c1 commit f6aebf5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/back-office/src/app/components/custom-widget-style/custom-widget-style.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core';
77
import { ButtonModule } from '@oort-front/ui';
88
import { SafeRestService } from '@oort-front/safe';
99
import { debounceTime, takeUntil } from 'rxjs';
10+
import set from 'lodash/set';
11+
import get from 'lodash/get';
1012

1113
/** Default css style example to initialize the form and editor */
1214
const DEFAULT_STYLE = '';
@@ -74,7 +76,7 @@ export class CustomWidgetStyleComponent
7476
this.restService
7577
.post('style/scss-to-css', { scss }, { responseType: 'text' })
7678
.subscribe((css) => {
77-
this.widgetComp.widget.settings.widgetDisplay.style = value;
79+
set(this.widgetComp, 'widget.settings.widgetDisplay.style', value);
7880
this.styleApplied.innerText = css;
7981
document
8082
.getElementsByTagName('head')[0]
@@ -92,7 +94,7 @@ export class CustomWidgetStyleComponent
9294
if (widgetStyle) this.styleApplied = widgetStyle;
9395
else this.styleApplied = document.createElement('style');
9496

95-
const style = this.widgetComp.widget.settings.widgetDisplay.style;
97+
const style = get(this.widgetComp, 'widget.settings.widgetDisplay.style') || '';
9698
if (style) {
9799
this.formControl.setValue(style);
98100
this.initialStyle = style;

0 commit comments

Comments
 (0)