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)))
.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();