Fix missing value in some static option selects

Shoelace select initially rejects the value due to missing option, and needs to be re-set once our options have arrived
This commit is contained in:
nathan 2023-11-16 10:09:20 -07:00
parent 5eaf6a275f
commit 3cf4cbab9a
3 changed files with 13 additions and 0 deletions

View File

@ -91,6 +91,7 @@ export class Et2SelectAccount extends SelectAccountMixin(Et2StaticSelectMixin(Et
return Promise.all(fetch).then(() =>
{
this.requestUpdate("select_options");
this.value = this.value;
});
}

View File

@ -91,6 +91,12 @@ export class Et2SelectCategory extends Et2StaticSelectMixin(Et2Select)
{
this._static_options = cleanSelectOptions(options);
this.requestUpdate("select_options");
// Shoelace select has rejected our value due to missing option by now, so re-set it
this.updateComplete.then(() =>
{
this.value = this.value;
});
});
}
}

View File

@ -82,6 +82,12 @@ export const Et2StaticSelectMixin = <T extends Constructor<Et2WidgetWithSelect>>
{
this._static_options = new_static_options;
this.requestUpdate("select_options");
// Shoelace select may have rejected our value due to missing option by now, so re-set it
if(this.value && this.select && this.value !== this.select.value)
{
this.value = this.value;
}
}
/**