Et2Select: Move option rendering into its own function, call it for Et2SelectAccount. This fixes missing option/label in some cases

eg: Kanban edit column Add/Remove assigned
This commit is contained in:
nathan 2022-08-15 10:30:30 -06:00
parent 5ff0cd7451
commit ddee9a2b59
2 changed files with 24 additions and 7 deletions

View File

@ -47,6 +47,13 @@ export class Et2SelectAccount extends Et2Select
this.__accountType = 'accounts'; this.__accountType = 'accounts';
} }
firstUpdated(changedProperties?)
{
super.firstUpdated(changedProperties);
// Due to the different way Et2SelectAccount handles options, we call this explicitly
this._renderOptions();
}
set accountType(type : AccountType) set accountType(type : AccountType)
{ {
this.__accountType = type; this.__accountType = type;

View File

@ -117,13 +117,7 @@ export const Et2widgetWithSelectMixin = <T extends Constructor<LitElement>>(supe
if(changedProperties.has('select_options') || changedProperties.has("emptyLabel")) if(changedProperties.has('select_options') || changedProperties.has("emptyLabel"))
{ {
// Add in options as children to the target node // Add in options as children to the target node
if(this._optionTargetNode) this._renderOptions();
{
render(html`${this._emptyLabelTemplate()}
${repeat(<SelectOption[]>this.select_options, (option : SelectOption) => option.value, this._optionTemplate.bind(this))}`,
this._optionTargetNode
);
}
if(this.handleMenuSlotChange) if(this.handleMenuSlotChange)
{ {
this.handleMenuSlotChange(); this.handleMenuSlotChange();
@ -131,6 +125,22 @@ export const Et2widgetWithSelectMixin = <T extends Constructor<LitElement>>(supe
} }
} }
/**
* Render select_options as child DOM Nodes
* @protected
*/
protected _renderOptions()
{
// Add in options as children to the target node
if(this._optionTargetNode)
{
render(html`${this._emptyLabelTemplate()}
${repeat(<SelectOption[]>this.select_options, (option : SelectOption) => option.value, this._optionTemplate.bind(this))}`,
this._optionTargetNode
);
}
}
/** /**
* Overwritten as sometimes called before this._inputNode is available * Overwritten as sometimes called before this._inputNode is available
* *