fix mixup of this.value, Lion this.modelValue and old get/set_value

causing eg. numeric values not to be cast to string and therefore not selecting their option
This commit is contained in:
ralf 2022-06-02 16:12:38 +02:00
parent c251e2f185
commit a9e180a9fb
2 changed files with 8 additions and 21 deletions

View File

@ -164,7 +164,12 @@ export class Et2Select extends Et2WithSearchMixin(Et2InvokerMixin(Et2WidgetWithS
set_value(val)
{
this.value = val;
this.value = ""+val;
}
getValue()
{
return this.value;
}
/**

View File

@ -128,17 +128,6 @@ export const Et2widgetWithSelectMixin = dedupeMixin((superclass) =>
return super.formatter(v);
}
set_value(val)
{
let oldValue = this.modelValue;
// Make sure it's a string
val = "" + val;
this.modelValue = val
this.requestUpdate("value", oldValue);
}
/**
* Set the select options
*
@ -153,16 +142,9 @@ export const Et2widgetWithSelectMixin = dedupeMixin((superclass) =>
this.requestUpdate("select_options", old_options);
// if single selection and value does not match an option, use the first option
let first_option;
if (!this.multiple && !this.empty_label && !this.__select_options.filter(option => {
if (typeof first_option === 'undefined')
if (!this.multiple && !this.empty_label && !this.__select_options.filter(option => option.value === this.value).length)
{
first_option = option;
}
return option.value === this.value;
}).length && typeof first_option !== 'undefined')
{
this.set_value(first_option.value);
this.value = this.__select_options[0].value;
}
}