Skip to content

Commit 53421e3

Browse files
authored
Merge pull request #587 from cmorgancli/510-fix-tabindex-on-select
fix(Select) preserve native select tabIndex value
2 parents 8675b4e + 9434311 commit 53421e3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/select.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class FormSelect extends Component<FormSelectOptions> {
4444
wrapper: HTMLDivElement;
4545
selectOptions: (HTMLOptionElement | HTMLOptGroupElement)[];
4646
private _values: ValueStruct[];
47+
nativeTabIndex: number;
4748

4849
constructor(el: HTMLSelectElement, options: FormSelectOptions) {
4950
super(el, options, FormSelect);
@@ -56,6 +57,7 @@ export class FormSelect extends Component<FormSelectOptions> {
5657
};
5758

5859
this.isMultiple = this.el.multiple;
60+
this.nativeTabIndex = (this.el.tabIndex ?? -1);
5961
this.el.tabIndex = -1;
6062
this._values = [];
6163
this._setupDropdown();
@@ -258,6 +260,7 @@ export class FormSelect extends Component<FormSelectOptions> {
258260
this.input.ariaReadOnly = 'true';
259261
this.input.ariaRequired = this.el.hasAttribute('required').toString(); //setAttribute("aria-required", this.el.hasAttribute("required"));
260262
if (this.el.disabled) this.input.disabled = true; // 'true');
263+
this.input.setAttribute('tabindex', this.nativeTabIndex.toString());
261264

262265
const attrs = this.el.attributes;
263266
for (let i = 0; i < attrs.length; ++i) {

0 commit comments

Comments
 (0)