Skip to content

Commit

Permalink
fix: ensure aria-selected attribute is removed from the item clone (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Dec 5, 2024
1 parent d43919d commit 77d3ddf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/select/src/vaadin-select-base-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ export const SelectBaseMixin = (superClass) =>
*/
__appendValueItemElement(itemElement, parent) {
parent.appendChild(itemElement);
// Trigger observer that sets aria-selected attribute
// so that we can then synchronously remove it below.
if (itemElement.performUpdate) {
itemElement.performUpdate();
}
itemElement.removeAttribute('tabindex');
itemElement.removeAttribute('aria-selected');
itemElement.removeAttribute('role');
Expand Down
2 changes: 1 addition & 1 deletion packages/select/test/keyboard.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ describe('keyboard', () => {
expect(clone.textContent).to.be.equal(item.textContent);
});

['active', 'focused', 'focus-ring', 'role', 'tabindex'].forEach((attr) => {
['active', 'focused', 'focus-ring', 'role', 'tabindex', 'aria-selected'].forEach((attr) => {
it(`should remove ${attr} attribute from the item clone`, async () => {
await sendKeys({ press: 'Tab' });

Expand Down
4 changes: 3 additions & 1 deletion packages/select/test/select.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,18 @@ describe('vaadin-select', () => {
});

describe('default', () => {
it('should select items when alphanumeric keys are pressed', () => {
it('should select items when alphanumeric keys are pressed', async () => {
expect(menu.selected).to.be.equal(2);
keyDownChar(valueButton, 'o');
keyDownChar(valueButton, 'p');
keyDownChar(valueButton, 't');
await nextUpdate(menu);
expect(menu.selected).to.be.equal(0);
keyDownChar(valueButton, 'i');
keyDownChar(valueButton, 'o');
keyDownChar(valueButton, 'n');
keyDownChar(valueButton, '2');
await nextUpdate(menu);
expect(menu.selected).to.be.equal(1);
});
});
Expand Down

0 comments on commit 77d3ddf

Please sign in to comment.