From a9fe5241238b15328d85642bf65ee537f5107fdd Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 15 Dec 2022 11:31:56 -0700 Subject: [PATCH] Et2Select: Fix value got wrecked by fix_bad_value() when there are option groups --- api/js/etemplate/Et2Select/Et2Select.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/js/etemplate/Et2Select/Et2Select.ts b/api/js/etemplate/Et2Select/Et2Select.ts index 50a6edae41..3292b2d170 100644 --- a/api/js/etemplate/Et2Select/Et2Select.ts +++ b/api/js/etemplate/Et2Select/Et2Select.ts @@ -280,7 +280,8 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect) const valueArray = Array.isArray(this.value) ? this.value : (!this.value ? [] : this.value.toString().split(',')); // value not in options --> use emptyLabel, if exists, or first option otherwise - if(this.select_options.filter((option) => valueArray.find(val => val == option.value)).length === 0) + if(this.select_options.filter((option) => valueArray.find(val => val == option.value) || + Array.isArray(option.value) && option.value.filter(o => valueArray.find(val => val == o.value))).length === 0) { let oldValue = this.value; this.value = this.emptyLabel ? "" : "" + this.select_options[0]?.value;