Skip to content

Commit e30916d

Browse files
authored
Dropdown: Allow empty option (#20099)
Fixes #20029. If a dropdown property-editor is not marked as mandatory and is in single-mode, then an empty option is added to the top of the dropdown, so that the value can be unset. This doesn't apply to multiple-mode, as values can be deselected.
1 parent 3cc5715 commit e30916d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Umbraco.Web.UI.Client/src/packages/property-editors/dropdown/property-editor-ui-dropdown.element.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ export class UmbPropertyEditorUIDropdownElement
9898
} else {
9999
this.addFormControlElement(this.shadowRoot!.querySelector('umb-input-dropdown-list')!);
100100
}
101+
102+
if (!this.mandatory && !this._multiple) {
103+
this._options.unshift({ name: '', value: '', selected: false, invalid: false });
104+
}
101105
}
102106

103107
#onChange(event: CustomEvent & { target: UmbInputDropdownListElement }) {

0 commit comments

Comments
 (0)