diff --git a/web/src/elements/forms/SearchSelect.ts b/web/src/elements/forms/SearchSelect.ts index 8df447880..47cb0a87c 100644 --- a/web/src/elements/forms/SearchSelect.ts +++ b/web/src/elements/forms/SearchSelect.ts @@ -160,8 +160,8 @@ export class SearchSelect extends AKElement { shouldRenderGroups = false; groupedItems = [["", []]]; } - const renderGroup = (items: T[]): TemplateResult => { - return html`${items.map((obj) => { + const renderGroup = (items: T[], tabIndexStart: number): TemplateResult => { + return html`${items.map((obj, index) => { let desc = undefined; if (this.renderDescription) { desc = this.renderDescription(obj); @@ -177,6 +177,7 @@ export class SearchSelect extends AKElement { this.selectedObject = obj; this.open = false; }} + tabindex=${index + tabIndexStart} > ${desc === undefined ? this.renderElement(obj) @@ -205,6 +206,7 @@ export class SearchSelect extends AKElement { role="listbox" style="max-height:50vh;overflow-y:auto;" id=${this.dropdownUID} + tabindex="0" > ${this.blankable ? html` @@ -216,6 +218,7 @@ export class SearchSelect extends AKElement { this.selectedObject = undefined; this.open = false; }} + tabindex="0" > ${this.emptyOption} @@ -223,17 +226,17 @@ export class SearchSelect extends AKElement { ` : html``} ${shouldRenderGroups - ? html`${groupedItems.map(([group, items]) => { + ? html`${groupedItems.map(([group, items], idx) => { return html`

${group}

    - ${renderGroup(items)} + ${renderGroup(items, idx)}
`; })}` - : html`${renderGroup(groupedItems[0][1])}`} + : html`${renderGroup(groupedItems[0][1], 0)}`} `, this.dropdownContainer, @@ -259,6 +262,11 @@ export class SearchSelect extends AKElement { this.renderMenu(); }} @blur=${(ev: FocusEvent) => { + // For Safari, we get the
    element itself here when clicking on one of + // it's buttons, as the container has tabindex set + if ((ev.relatedTarget as HTMLElement).id === this.dropdownUID) { + return; + } // Check if we're losing focus to one of our dropdown items, and if such don't blur if (ev.relatedTarget instanceof HTMLButtonElement) { const parentMenu = ev.relatedTarget.closest(