Skip to content

Commit

Permalink
Merge pull request materializecss#587 from cmorgancli/510-fix-tabinde…
Browse files Browse the repository at this point in the history
…x-on-select

fix(Select) preserve native select tabIndex value
  • Loading branch information
wuda-io authored Jan 30, 2025
2 parents 8675b4e + 9434311 commit 53421e3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class FormSelect extends Component<FormSelectOptions> {
wrapper: HTMLDivElement;
selectOptions: (HTMLOptionElement | HTMLOptGroupElement)[];
private _values: ValueStruct[];
nativeTabIndex: number;

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

this.isMultiple = this.el.multiple;
this.nativeTabIndex = (this.el.tabIndex ?? -1);
this.el.tabIndex = -1;
this._values = [];
this._setupDropdown();
Expand Down Expand Up @@ -258,6 +260,7 @@ export class FormSelect extends Component<FormSelectOptions> {
this.input.ariaReadOnly = 'true';
this.input.ariaRequired = this.el.hasAttribute('required').toString(); //setAttribute("aria-required", this.el.hasAttribute("required"));
if (this.el.disabled) this.input.disabled = true; // 'true');
this.input.setAttribute('tabindex', this.nativeTabIndex.toString());

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

0 comments on commit 53421e3

Please sign in to comment.