Fix duplicate option warning from customfield select filter

This commit is contained in:
nathan 2022-10-18 16:06:28 -06:00
parent 323e45caf7
commit 48eb9c1968
2 changed files with 7 additions and 3 deletions

View File

@ -147,7 +147,10 @@ export const Et2widgetWithSelectMixin = <T extends Constructor<LitElement>>(supe
*/ */
let temp_target = document.createElement("div"); 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); render(options, temp_target);
return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render))) return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render)))

View File

@ -4119,9 +4119,10 @@ export class et2_nextmatch_customfields extends et2_customfields_list implements
let widget = null; let widget = null;
if(field.type == 'select' || field.type == 'select-account') 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( widget = loadWebComponent(
field.type == 'select-account' ? 'et2-nextmatch-header-account' : "et2-nextmatch-header-filter", field.type == 'select-account' ? 'et2-nextmatch-header-account' : "et2-nextmatch-header-filter",