Fix changing select options did not properly clear previous options

This commit is contained in:
nathan 2022-10-07 15:31:06 -06:00
parent 01a08447cb
commit 8514792efc

View File

@ -153,14 +153,10 @@ export const Et2widgetWithSelectMixin = <T extends Constructor<LitElement>>(supe
return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render))) return Promise.all(([...temp_target.querySelectorAll(":scope > *")].map(item => item.render)))
.then(() => .then(() =>
{ {
temp_target.querySelectorAll(":scope > *").forEach((item) => this._optionTargetNode.replaceChildren(
{ ...Array.from(temp_target.querySelectorAll(":scope > *")),
// Avoid duplicate error ...Array.from(this._optionTargetNode.querySelectorAll(":scope > [slot]"))
if(!this._optionTargetNode.querySelector("[value='" + item.value.replace(/'/g, '\\\'') + "']")) );
{
this._optionTargetNode.appendChild(item);
}
});
if(typeof this.handleMenuSlotChange == "function") if(typeof this.handleMenuSlotChange == "function")
{ {
this.handleMenuSlotChange(); this.handleMenuSlotChange();