Dropdown: Support migrated empty values (closes #20029) (#20247)

* Display the latest update date in document collection view

* Don't consider "" as a missing option when initializing the drop down list.

* Don't flag "" as a missing option when validatng server-side.

---------

Co-authored-by: Laura Neto <12862535+lauraneto@users.noreply.github.com>
This commit is contained in:
Andy Butland
2025-09-24 09:48:47 +02:00
committed by GitHub
parent 8c25295294
commit 36d46624bf
3 changed files with 5 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ public class MultipleValueValidator : IValueValidator
}
var invalidValues = values
.Where(x => valueListConfiguration.Items.Contains(x) is false)
.Where(x => x.IsNullOrWhiteSpace() is false && valueListConfiguration.Items.Contains(x) is false)
.ToList();
if (invalidValues.Count == 1)

View File

@@ -78,7 +78,7 @@ export class UmbPropertyEditorUIDropdownElement
// If selection includes a value that is not in the list, add it to the list
this.#selection.forEach((value) => {
if (!this._options.find((item) => item.value === value)) {
if (value !== '' && !this._options.find((item) => item.value === value)) {
this._options.push({
name: `${value} (${this.localize.term('validation_legacyOption')})`,
value,
@@ -109,7 +109,7 @@ export class UmbPropertyEditorUIDropdownElement
this.#setValue(value ? [value] : []);
}
#onChangeMulitple(event: Event & { target: HTMLSelectElement }) {
#onChangeMultiple(event: Event & { target: HTMLSelectElement }) {
const selected = event.target.selectedOptions;
const value = selected ? Array.from(selected).map((option) => option.value) : [];
this.#setValue(value);
@@ -155,7 +155,7 @@ export class UmbPropertyEditorUIDropdownElement
}
return html`
<select id="native" multiple ?required=${this.mandatory} @change=${this.#onChangeMulitple}>
<select id="native" multiple ?required=${this.mandatory} @change=${this.#onChangeMultiple}>
${map(
this._options,
(item) => html`<option value=${item.value} ?selected=${item.selected}>${item.name}</option>`,

View File

@@ -128,6 +128,7 @@ public class MultiValuePropertyEditorTests
Assert.AreEqual("Item 3", result.Items[2]);
}
[TestCase("", true, "")]
[TestCase("Red", true, "")]
[TestCase("Yellow", false, "notOneOfOptions")]
[TestCase("Red,Green", true, "")]