Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility Bug #303

Open
long2know opened this issue Feb 23, 2021 · 1 comment
Open

Accessibility Bug #303

long2know opened this issue Feb 23, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@long2know
Copy link

Currently, when the mat-select w/ ngx-mat-select-search is expanded, the number of items is misreported using NVDA.

In the speech viewer, we see something like this upon expansion:

My list    combo box  collapsed  required  invalid entry  Selection is required
expanded
table
My list
(Item1) - Item1 2 of 49
dropdown search  edit  unavailable  Type to filter list by name  blank

In my test, there are actually (48) items and the initial item selected should be (1 of 48).

Additionally, when the items in the list are filtered, there is no announcement of the number of items that are currently in the list. Comparing to other filterable components, such as material typeahead, the number of items that are available are announced in NVDA.

@long2know long2know added the bug Something isn't working label Feb 23, 2021
@macjohnny
Copy link
Member

@long2know would you like to improve the accessibility?

the relevant code is located here:

this.liveAnnouncer.announce(
activeDescendant.viewValue + ' '
+ this.getAriaIndex(index)
+ this.indexAndLengthScreenReaderText
+ this.getAriaLength()
);
}
}
}
/**
* Calculate the index of the current option, taking the offset to length into account.
* examples:
* Case 1 [Search, 1, 2, 3] will have offset of 1, due to search and will read index of total.
* Case 2 [1, 2, 3] will have offset of 0 and will read index +1 of total.
*/
getAriaIndex(optionIndex: number): number {
if (this.getOptionsLengthOffset() === 0) {
return optionIndex + 1;
}
return optionIndex;
}
/**
* Calculate the length of the options, taking the offset to length into account.
* examples:
* Case 1 [Search, 1, 2, 3] will have length of options.length -1, due to search.
* Case 2 [1, 2, 3] will have length of options.length.
*/
getAriaLength(): number {
return this._options.toArray().length - this.getOptionsLengthOffset();
}

  • the offset should be easy to fix
  • the total number of items to be announced should be passed as an input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants