Et2Select: Add tabindex to options to avoid focus stealing in sidemenu, other event handling cleanup

This commit is contained in:
nathan 2023-10-12 11:25:23 -06:00
parent f15cbd186f
commit 5601b99c97
2 changed files with 10 additions and 4 deletions

View File

@ -576,7 +576,6 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
{
super.et2HandleBlur(event);
}
this.dropdown?.hide();
}
@ -834,6 +833,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
?clearable=${this.clearable}
?required=${this.required}
helpText=${this.helpText}
tabindex="0"
hoist
placement=${this.placement}
.getTag=${this._tagTemplate}

View File

@ -147,7 +147,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
display: none;
}
:host([search][multiple]) sl-select[open]::part(expand-icon) {
:host([search]) sl-select[open]::part(expand-icon) {
display: none;
}
@ -398,6 +398,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
// One of the key properties has changed, need to add the needed nodes
if(changedProperties.has("search") || changedProperties.has("editModeEnabled") || changedProperties.has("allowFreeEntries"))
{
this._unbindListeners();
// Missing any of the required attributes? Now we need to take it out.
if(!this.searchEnabled && !this.editModeEnabled && !this.allowFreeEntries || this.readonly)
{
@ -405,8 +406,8 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
return;
}
// Normally this should be handled in render(), but we have to add our nodes in
//this._addNodes();
// Listeners may have been skipped from connectedCallback()
this._bindListeners();
}
// Update any tags if edit mode changes
if(changedProperties.has("editModeEnabled") || changedProperties.has("readonly"))
@ -417,6 +418,11 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
tag.editable = this.editModeEnabled && !this.readonly;
tag.removable = !this.readonly;
});
if(this.readonly)
{
this._unbindListeners();
}
}
}