vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.15k stars 1.38k forks source link

[Accessibility improvement] Add ability to explicitly set treeitems number and position #2450

Closed Karkhutvy closed 4 years ago

Karkhutvy commented 4 years ago

Aria-posinset and aria-setsize attributes is used by screen readers to define and announce tree element position and elements number. By default, these attributes are computed by the browser. And ARIA 1.1 says for them “If all items in a set are present in the document structure, it is not necessary to set this property, as the user agent can automatically calculate the set size and position for each item”.

But different browsers compute these properties differently. And for different combinations of screen readers and browsers -problems with elements position announcement can be appeared. Such problems are described in scope of https://github.com/vakata/jstree/issues/2448.

To fix them new option "compute_elements_positions" was introduced:

Force to compute and set "aria-setsize" and "aria-posinset" explicitly for each treeitem. Some browsers may compute incorrect elements position and produce wrong announcements for screen readers. Defaults to false

If user wants to increase compatibility for more browsers and screen readers combination, he can turn on this option. It will explicitly compute values of aria-posinset and aria-setsize attributes inside jsTree and set them for tree items. Different browsers and screen readers works more stable if we set these attributes explicitly.