Et2Select: If somebody set '' as an option value then '' is not a bad value and doesn't need to be fixed.

This commit is contained in:
nathan 2022-09-01 09:58:08 -06:00
parent 64e2fb7c63
commit 24daafb9ef

View File

@ -242,6 +242,11 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
{ {
return; return;
} }
// If somebody gave '' as a select_option, let it be
if(this.value === '' && this.select_options.filter((option) => this.value === option.value).length == 1)
{
return;
}
// If no value is set, choose the first option // If no value is set, choose the first option
// Only do this on once during initial setup, or it can be impossible to clear the value // Only do this on once during initial setup, or it can be impossible to clear the value
const valueArray = Array.isArray(this.value) ? this.value : (!this.value ? [] : this.value.toString().split(',')); const valueArray = Array.isArray(this.value) ? this.value : (!this.value ? [] : this.value.toString().split(','));