Skip to content

Commit

Permalink
fix: change tabindex from 0 to -1 when focusing first item
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Mar 18, 2024
1 parent d6d9246 commit ace4b62
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions test/vaadin-list-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@
list.focus();
expect(spy.calledOnce).to.be.true;
});

it('should change tabindex from -1 to 0 on first non-disabled item when focusing it', () => {
list.items.forEach((item) => {
item.tabIndex = -1;
});
list.focus();
[-1, -1, 0, -1].forEach((val, idx) => expect(list.items[idx].tabIndex).to.equal(val));
});
});

describe('tabIndex when all the items are disabled', () => {
Expand Down
2 changes: 1 addition & 1 deletion vaadin-list-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
} else if (this.items) {
const idx = this._getAvailableIndex(0, null, item => !item.disabled);
if (idx >= 0) {
this.items[idx].focus();
this._focus(idx);
}
}
}
Expand Down

0 comments on commit ace4b62

Please sign in to comment.