From 8514792efc45b5d5cf9378a6f667d36ce73745bb Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 7 Oct 2022 15:31:06 -0600 Subject: [PATCH] Fix changing select options did not properly clear previous options --- .../etemplate/Et2Select/Et2WidgetWithSelectMixin.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts b/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts index 9c5f15d7e6..7c17492d75 100644 --- a/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts +++ b/api/js/etemplate/Et2Select/Et2WidgetWithSelectMixin.ts @@ -153,14 +153,10 @@ export const Et2widgetWithSelectMixin = >(supe return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render))) .then(() => { - temp_target.querySelectorAll(":scope > *").forEach((item) => - { - // Avoid duplicate error - if(!this._optionTargetNode.querySelector("[value='" + item.value.replace(/'/g, '\\\'') + "']")) - { - this._optionTargetNode.appendChild(item); - } - }); + this._optionTargetNode.replaceChildren( + ...Array.from(temp_target.querySelectorAll(":scope > *")), + ...Array.from(this._optionTargetNode.querySelectorAll(":scope > [slot]")) + ); if(typeof this.handleMenuSlotChange == "function") { this.handleMenuSlotChange();