From a9d2a3972cde0389e3c52add07a638f08cc0942e Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 3 Apr 2023 08:52:31 -0600 Subject: [PATCH] Et2Select: It was impossible to have "," as an option value, as it would get split by fix_bad_value() --- api/js/etemplate/Et2Select/Et2Select.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/js/etemplate/Et2Select/Et2Select.ts b/api/js/etemplate/Et2Select/Et2Select.ts index dbffefa3b7..dd2b242e9a 100644 --- a/api/js/etemplate/Et2Select/Et2Select.ts +++ b/api/js/etemplate/Et2Select/Et2Select.ts @@ -436,7 +436,9 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) } // 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 - 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.multiple ? this.value.toString().split(',') : [this.value]) + ); // value not in options --> use emptyLabel, if exists, or first option otherwise if(this.select_options.filter((option) => valueArray.find(val => val == option.value) || @@ -462,7 +464,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) set_value(val : string | string[] | number | number[]) { - if(typeof val === 'string' && val.indexOf(',') !== -1) + if(typeof val === 'string' && val.indexOf(',') !== -1 && (this.multiple || val.length >= 3)) { val = val.split(','); }