From 544aafc8edef114253b650d8b4e61658f5b1ae99 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 14 Mar 2024 09:42:03 +0100 Subject: [PATCH] fix: assume the value isn't set by default (some migrations may have deleted it) Approved-By: leekelleher --- ...i-collection-view-column-configuration.element.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/config/column-configuration/property-editor-ui-collection-view-column-configuration.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/config/column-configuration/property-editor-ui-collection-view-column-configuration.element.ts index b15e99421c..ac99056914 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/config/column-configuration/property-editor-ui-collection-view-column-configuration.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/property-editor/uis/collection-view/config/column-configuration/property-editor-ui-collection-view-column-configuration.element.ts @@ -16,7 +16,7 @@ export class UmbPropertyEditorUICollectionViewColumnConfigurationElement implements UmbPropertyEditorUiElement { @property({ type: Array }) - value: Array = []; + value?: Array = []; @property({ type: Object, attribute: false }) public config?: UmbPropertyEditorConfigCollection; @@ -31,7 +31,7 @@ export class UmbPropertyEditorUICollectionViewColumnConfigurationElement this._field = element.selectedProperty; - const duplicate = this.value.find((config) => this._field?.alias === config.alias); + const duplicate = this.value?.find((config) => this._field?.alias === config.alias); if (duplicate) { // TODO: Show error to user, can not add duplicate field/column. [LK] @@ -44,7 +44,7 @@ export class UmbPropertyEditorUICollectionViewColumnConfigurationElement isSystem: this._field.isSystem ? 1 : 0, }; - this.value = [...this.value, config]; + this.value = [...(this.value ?? []), config]; this.dispatchEvent(new UmbPropertyValueChangeEvent()); } @@ -52,7 +52,7 @@ export class UmbPropertyEditorUICollectionViewColumnConfigurationElement #onRemove(unique: string) { const newValue: Array = []; - this.value.forEach((config) => { + this.value?.forEach((config) => { if (config.alias !== unique) newValue.push(config); }); @@ -61,7 +61,7 @@ export class UmbPropertyEditorUICollectionViewColumnConfigurationElement } #onHeaderChange(e: UUIInputEvent, configuration: UmbCollectionColumnConfiguration) { - this.value = this.value.map( + this.value = this.value?.map( (config): UmbCollectionColumnConfiguration => config.alias === configuration.alias ? { ...config, header: e.target.value as string } : config, ); @@ -70,7 +70,7 @@ export class UmbPropertyEditorUICollectionViewColumnConfigurationElement } #onTemplateChange(e: UUIInputEvent, configuration: UmbCollectionColumnConfiguration) { - this.value = this.value.map( + this.value = this.value?.map( (config): UmbCollectionColumnConfiguration => config.alias === configuration.alias ? { ...config, nameTemplate: e.target.value as string } : config, );