Skip to content

Commit efacf9a

Browse files
committed
Slack: Report suggestions in various autocompletes such as the Quick Switcher and direct messages menu.
This is currently done with a live region, since ARIA autocompletes don't work so well for autocompletes where the first item is selected as you type.
1 parent 65f7d7c commit efacf9a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

SlackA11yFixes.user.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,16 @@ function setStarred(elem) {
3636
elem.classList.contains("starred") ? "true" : "false");
3737
}
3838

39-
function message(text) {
39+
function message(text, suppressRepeats) {
4040
var live = document.getElementById("aria_live_announcer");
41-
live.textContent = text;
41+
if (suppressRepeats && live.textContent == text) {
42+
return;
43+
}
44+
// Use a new div so this is treated as an addition, not a text change.
45+
// Otherwise, the browser will attempt to calculate a diff between old and new text,
46+
// which could result in partial reporting or nothing depending on the previous text.
47+
live.innerHTML = "<div></div>";
48+
live.firstChild.textContent = text;
4249
}
4350

4451
function onNodeAdded(target) {
@@ -102,6 +109,13 @@ function onClassModified(target) {
102109
if (classes.contains("star")) {
103110
// Starred state changed.
104111
setStarred(target);
112+
} else if (classes.contains("highlighted")) {
113+
// Autocomplete selection.
114+
// We use a live region because ARIA autocompletes don't work so well
115+
// for a control which selects the first item as you type.
116+
// This gets fired every time you type, even if the item doesn't change.
117+
// Therefore, suppress repeated reports.
118+
message(target.textContent, true);
105119
}
106120
}
107121

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ It does the following:
7979
- Makes the current channel title, day separators in the message history, the headers of individual search results and the headers of individual threads in All Threads accessible as headings.
8080
- Reports incoming messages automatically (using a live region).
8181
- Hides an editable area which isn't shown visually.
82+
- Reports suggestions in various autocompletes such as the Quick Switcher and direct messages menu.
8283

8384
### Telegram accessibility fixes
8485
[Download Telegram Accessibility Fixes](https://github.com/nvaccess/axSGrease/raw/master/TelegramA11yFixes.user.js)

0 commit comments

Comments
 (0)