document type picker value undefined when empty

This commit is contained in:
Niels Lyngsø
2024-06-19 10:29:28 +02:00
parent 08f0af3798
commit 013e1c9dae
2 changed files with 9 additions and 6 deletions

View File

@@ -8,10 +8,13 @@ import { UmbChangeEvent } from '@umbraco-cms/backoffice/event';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/router';
import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';
import { UUIFormControlMixin } from '@umbraco-cms/backoffice/external/uui';
import { UmbFormControlMixin } from '@umbraco-cms/backoffice/validation';
@customElement('umb-input-document-type')
export class UmbInputDocumentTypeElement extends UUIFormControlMixin(UmbLitElement, '') {
export class UmbInputDocumentTypeElement extends UmbFormControlMixin<string | undefined, typeof UmbLitElement>(
UmbLitElement,
undefined,
) {
#sorter = new UmbSorterController<string>(this, {
getUniqueOfElement: (element) => {
return element.id;
@@ -102,11 +105,11 @@ export class UmbInputDocumentTypeElement extends UUIFormControlMixin(UmbLitEleme
}
@property()
public set value(uniques: string) {
public set value(uniques: string | undefined) {
this.selection = splitStringToArray(uniques);
}
public get value(): string {
return this.selection.join(',');
public get value(): string | undefined {
return this.selection.length > 0 ? this.selection.join(',') : undefined;
}
@state()
private _items?: Array<UmbDocumentTypeItemModel>;

View File

@@ -35,7 +35,7 @@ export class UmbPropertyEditorUIDocumentTypePickerElement extends UmbLitElement
onlyElementTypes?: boolean;
#onChange(event: CustomEvent & { target: UmbInputDocumentTypeElement }) {
this.value = event.target.selection.join(',');
this.value = event.target.value;
this.dispatchEvent(new UmbPropertyValueChangeEvent());
}