From 48eb9c196823b3095580563021096fb10b79e4a6 Mon Sep 17 00:00:00 2001 From: nathan Date: Tue, 18 Oct 2022 16:06:28 -0600 Subject: [PATCH] Fix duplicate option warning from customfield select filter --- api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts | 5 ++++- api/js/etemplate/et2_extension_nextmatch.ts | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts b/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts index 7c17492d75..eafd9d101a 100644 --- a/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts +++ b/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts @@ -147,7 +147,10 @@ export const Et2widgetWithSelectMixin = >(supe */ let temp_target = document.createElement("div"); - let options = html`${this._emptyLabelTemplate()}${this.select_options.map(this._optionTemplate.bind(this))}`; + let options = html`${this._emptyLabelTemplate()}${this.select_options + // Filter out empty values if we have empty label to avoid duplicates + .filter(o => this.emptyLabel ? o.value !== '' : o) + .map(this._optionTemplate.bind(this))}`; render(options, temp_target); return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render))) diff --git a/api/js/etemplate/et2_extension_nextmatch.ts b/api/js/etemplate/et2_extension_nextmatch.ts index d8ef2616ce..c15976b9c5 100644 --- a/api/js/etemplate/et2_extension_nextmatch.ts +++ b/api/js/etemplate/et2_extension_nextmatch.ts @@ -4119,9 +4119,10 @@ export class et2_nextmatch_customfields extends et2_customfields_list implements let widget = null; if(field.type == 'select' || field.type == 'select-account') { - if(field.values && typeof field.values[''] !== 'undefined') + // Remove empty label + if(field.values && field.values.findIndex && field.values.findIndex((i) => i.value == '') !== -1) { - delete (field.values['']); + field.values.splice(field.values.findIndex((i) => i.value == ''), 1); } widget = loadWebComponent( field.type == 'select-account' ? 'et2-nextmatch-header-account' : "et2-nextmatch-header-filter",