Fix option merge unique filter left out some options

This commit is contained in:
nathan 2022-07-19 10:30:48 -06:00
parent f79c57f048
commit 5ee60c0af1

View File

@ -46,18 +46,10 @@ export const Et2StaticSelectMixin = <T extends Constructor<Et2WidgetWithSelect>>
// @ts-ignore
const options = super.select_options || [];
// make sure result is unique
if (options.length && this.static_options.length)
{
const union = [].concat(options);
this.static_options.forEach(option => {
if (!union.filter(opt => opt.value == option.value).length)
{
union.concat(option);
}
});
return union;
}
return [...options, ...(this.static_options || [])];
return [...new Map([...options, ...(this.static_options || [])].map(item =>
[item.value, item])).values()];
}
set select_options(new_options)