Skip to content

Commit 6bda176

Browse files
committed
only set tabindex on this targets
1 parent 076392e commit 6bda176

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

packages/uui-base/lib/mixins/SelectableMixin.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ export const SelectableMixin = <T extends Constructor<LitElement>>(
5656
this._selectable = newVal;
5757

5858
// Potentially problematic as a component might need focus for another feature when not selectable:
59-
//if (this.#selectableTarget === this) {
60-
// If the selectable target, then make it self selectable. (A different selectable target should be made focusable by the component itself)
61-
this.#selectableTarget.setAttribute('tabindex', `${newVal ? '0' : '-1'}`);
62-
//}
59+
if (this.#selectableTarget === this) {
60+
// If the selectable target, then make it self selectable. (A different selectable target should be made focusable by the component itself)
61+
this.#selectableTarget.setAttribute(
62+
'tabindex',
63+
`${newVal ? '0' : '-1'}`,
64+
);
65+
}
6366
this.requestUpdate('selectable', oldVal);
6467
}
6568

@@ -88,10 +91,13 @@ export const SelectableMixin = <T extends Constructor<LitElement>>(
8891
);
8992

9093
this.#selectableTarget = target as Element;
91-
this.#selectableTarget.setAttribute(
92-
'tabindex',
93-
this._selectable ? '0' : '-1',
94-
);
94+
if (this.#selectableTarget === this) {
95+
// If the selectable target, then make it self selectable. (A different selectable target should be made focusable by the component itself)
96+
this.#selectableTarget.setAttribute(
97+
'tabindex',
98+
this._selectable ? '0' : '-1',
99+
);
100+
}
95101
target.addEventListener('click', this.#onClick);
96102
target.addEventListener('keydown', this.#onKeydown as EventListener);
97103
}

0 commit comments

Comments
 (0)