mirror of
https://github.com/Choices-js/Choices.git
synced 2026-03-14 22:55:46 +01:00
Avoid triple state: aria-selected=("true"|"false"|unset)
This commit is contained in:
parent
d177c925c1
commit
d4e8eebc9d
2 changed files with 21 additions and 0 deletions
|
|
@ -322,6 +322,7 @@ const templates: TemplatesInterface = {
|
|||
} else {
|
||||
addClassesToElement(div, itemSelectable);
|
||||
div.dataset.choiceSelectable = '';
|
||||
div.setAttribute('aria-selected', 'false');
|
||||
}
|
||||
|
||||
return div;
|
||||
|
|
|
|||
|
|
@ -147,6 +147,26 @@ describe(`Choices - select multiple`, () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('aria attributes', () => {
|
||||
const testId = 'disabled-choice';
|
||||
test('aria-selected', async ({ page, bundle }) => {
|
||||
const suite = new SelectTestSuit(page, bundle, testUrl, testId);
|
||||
await suite.startWithClick();
|
||||
|
||||
await suite.input.press('ArrowDown');
|
||||
await expect(suite.choices.first()).toHaveAttribute("aria-selected", "false");
|
||||
await expect(suite.choices.nth(1)).toHaveAttribute("aria-selected", "true");
|
||||
await expect(suite.choices.nth(2)).toHaveAttribute("aria-selected", "false");
|
||||
await expect(suite.choices.nth(3)).not.toHaveAttribute("aria-selected");
|
||||
|
||||
await suite.input.press('ArrowUp');
|
||||
await expect(suite.choices.first()).toHaveAttribute("aria-selected", "true");
|
||||
await expect(suite.choices.nth(1)).toHaveAttribute("aria-selected", "false");
|
||||
await expect(suite.choices.nth(2)).toHaveAttribute("aria-selected", "false");
|
||||
await expect(suite.choices.nth(3)).not.toHaveAttribute("aria-selected");
|
||||
});
|
||||
});
|
||||
|
||||
describe('searching choices', () => {
|
||||
const validValue = 'item2';
|
||||
const validLabelForValue = 'Choice 2';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue