Et2Select: Pressing tab on empty search moves focus to next element

This commit is contained in:
nathan 2023-11-22 11:52:49 -07:00
parent c6485ebd4f
commit 7195ea09b2
3 changed files with 17 additions and 3 deletions

View File

@ -764,6 +764,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
icon:icon
"
class=${"search_tag " + option.classList.value}
tabindex="-1"
?pill=${this.pill}
size=${this.size || "medium"}
?removable=${!readonly}
@ -828,7 +829,6 @@ 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

@ -470,6 +470,7 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
exportparts="base:search__base"
clearable
autocomplete="off"
tabindex="-1"
placeholder="${this.egw().lang("search")}"
style="flex: 1 1 auto;"
@keydown=${this._handleSearchKeyDown}
@ -952,6 +953,19 @@ export const Et2WithSearchMixin = dedupeMixin(<T extends Constructor<LitElement>
// TODO
return;
}
else if(event.key == "Tab" && !this._searchInputNode.value)
{
// Mess with tabindexes to allow focus to easily go to next control
const input = this.select.shadowRoot.querySelector('[tabindex="0"]');
input.setAttribute("tabindex", "-1");
this.updateComplete.then(() =>
{
// Set it back so we can get focus again later
input.setAttribute("tabindex", "0");
})
// Allow to propagate
return;
}
event.stopPropagation();
// Don't allow event to bubble or it will interact with select

View File

@ -264,7 +264,7 @@ export class Et2EmailTag extends Et2Tag
const option = Et2EmailTag.email_cache[this.value];
button_or_avatar = html`
<et2-lavatar slot="prefix" part="icon"
<et2-lavatar slot="prefix" part="icon" tabindex="-1"
@mousedown=${this.handleContactMouseDown}
.size=${style.getPropertyValue("--icon-width")}
lname=${option.lname || nothing}
@ -279,7 +279,7 @@ export class Et2EmailTag extends Et2Tag
// Show a button to add as new contact
classes['tag__has_plus'] = true;
button_or_avatar = html`
<et2-button-icon image="add" @mousedown=${this.handleMouseDown}
<et2-button-icon image="add" tabindex="-1" @mousedown=${this.handleMouseDown}
label="${this.egw().lang("Add a new contact")}"
statustext="${this.egw().lang("Add a new contact")}">
</et2-button-icon>`;