Skip to content

Commit 77d3ddf

Browse files
authored
fix: ensure aria-selected attribute is removed from the item clone (#8275)
1 parent d43919d commit 77d3ddf

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

packages/select/src/vaadin-select-base-mixin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,11 @@ export const SelectBaseMixin = (superClass) =>
461461
*/
462462
__appendValueItemElement(itemElement, parent) {
463463
parent.appendChild(itemElement);
464+
// Trigger observer that sets aria-selected attribute
465+
// so that we can then synchronously remove it below.
466+
if (itemElement.performUpdate) {
467+
itemElement.performUpdate();
468+
}
464469
itemElement.removeAttribute('tabindex');
465470
itemElement.removeAttribute('aria-selected');
466471
itemElement.removeAttribute('role');

packages/select/test/keyboard.common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe('keyboard', () => {
151151
expect(clone.textContent).to.be.equal(item.textContent);
152152
});
153153

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

packages/select/test/select.common.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,18 @@ describe('vaadin-select', () => {
231231
});
232232

233233
describe('default', () => {
234-
it('should select items when alphanumeric keys are pressed', () => {
234+
it('should select items when alphanumeric keys are pressed', async () => {
235235
expect(menu.selected).to.be.equal(2);
236236
keyDownChar(valueButton, 'o');
237237
keyDownChar(valueButton, 'p');
238238
keyDownChar(valueButton, 't');
239+
await nextUpdate(menu);
239240
expect(menu.selected).to.be.equal(0);
240241
keyDownChar(valueButton, 'i');
241242
keyDownChar(valueButton, 'o');
242243
keyDownChar(valueButton, 'n');
243244
keyDownChar(valueButton, '2');
245+
await nextUpdate(menu);
244246
expect(menu.selected).to.be.equal(1);
245247
});
246248
});

0 commit comments

Comments
 (0)