a11y: clear aria-expanded on empty itemTree rows (#5201)

Per https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-expanded#treeitems
only treeitems that contain children should have
the aria-expanded attribute. This is instead of having
aria-expanded="false" on empty regular items or standalone
attachments, which erroneously indicates to screen readers
that the row has children but is collapsed.

Fixes: #5200
This commit is contained in:
abaevbog 2025-04-15 22:53:54 -07:00 committed by Dan Stillman
parent ec59f43a68
commit a7e1035b77

View file

@ -3097,7 +3097,10 @@ var ItemTree = class ItemTree extends LibraryTree {
// Accessibility
div.setAttribute('role', 'treeitem');
div.setAttribute('aria-level', this.getLevel(index) + 1);
if (!this.isContainerEmpty(index)) {
if (this.isContainerEmpty(index)) {
div.removeAttribute('aria-expanded');
}
else {
div.setAttribute('aria-expanded', this.isContainerOpen(index));
}
if (rowData.contextRow) {