Show empty_label when given a value that is not in the list of options

This commit is contained in:
nathan 2022-02-23 13:13:14 -07:00
parent 41a18b6274
commit f0455b2ad2

View File

@ -78,6 +78,10 @@ export class Et2WidgetWithSelect extends Et2InputWidget(LionSelect)
set_value(val)
{
let oldValue = this.modalValue;
// Make sure it's a string
val = "" + val;
this.modalValue = val
this.requestUpdate("value", oldValue);
}
@ -229,6 +233,11 @@ export class Et2Select extends Et2WidgetWithSelect
}
if(changedProperties.has('select_options') || changedProperties.has("value"))
{
if(this.get_select_options().length > 0 && this.get_select_options().filter((option) => option.value == this.modalValue).length === 0)
{
// Not in list, clear it
this.modalValue = "";
}
// Re-set value, the option for it may have just shown up
this._inputNode.value = this.modalValue || "";
}