Skip to content

Commit

Permalink
static/frontend: fix for screen reader to announce dynamic updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
Prudhvi Krishna Chintala authored and jamalc committed Aug 22, 2023
1 parent ac6b0dd commit deea662
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion static/frontend/unit/main/main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions static/frontend/unit/main/main.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions static/frontend/unit/main/main.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
{{end}}
</div>
</div>
<div id="showInternal-description" hidden> Click to show internal directories. </div>
<div id="hideInternal-description" hidden> Click to hide internal directories. </div>
{{end}}

{{define "main-scripts"}}
Expand Down
8 changes: 8 additions & 0 deletions static/frontend/unit/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ if (directories) {
if (internalToggle) {
if (document.querySelector('.UnitDirectories-internal')) {
internalToggle.style.display = 'block';
internalToggle.setAttribute('aria-label', 'Show Internal Directories');
internalToggle.setAttribute('aria-describedby', 'showInternal-description');
}
internalToggle.addEventListener('click', () => {
if (directories.classList.contains('UnitDirectories-showInternal')) {
directories.classList.remove('UnitDirectories-showInternal');
internalToggle.innerText = 'Show internal';
internalToggle.setAttribute('aria-label', 'Show Internal Directories');
internalToggle.setAttribute('aria-live', 'polite');
internalToggle.setAttribute('aria-describedby', 'showInternal-description');
} else {
directories.classList.add('UnitDirectories-showInternal');
internalToggle.innerText = 'Hide internal';
internalToggle.setAttribute('aria-label', 'Hide Internal Directories');
internalToggle.setAttribute('aria-live', 'polite');
internalToggle.setAttribute('aria-describedby', 'hideInternal-description');
}
});
}
Expand Down
4 changes: 4 additions & 0 deletions static/shared/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ export class ExpandableRowsTableController {
if (someCollapsed) {
this.toggleAll.innerText = 'Expand all';
this.toggleAll.onclick = this.expandAllItems;
this.toggleAll.setAttribute('aria-label', 'Expand all directories');
this.toggleAll.setAttribute('aria-live', 'polite');
} else {
this.toggleAll.innerText = 'Collapse all';
this.toggleAll.onclick = this.collapseAllItems;
this.toggleAll.setAttribute('aria-label', 'Collapse all directories');
this.toggleAll.setAttribute('aria-live', 'polite');
}
}
}

0 comments on commit deea662

Please sign in to comment.