Skip to content

Commit 699cf74

Browse files
JohnMcLearclaude
andcommitted
fix(a11y): set #online_count aria-label on init (#7777 CI fix)
The Playwright spec added in 987bb3a failed because aria-label was null on first paint. updateNumberOfOnlineUsers — which writes the localized aria-label — only fires on userJoin / userLeave / status change. On a solo-author pad those events never arrive, so the badge shipped to AT with no accessible name (and no PR-fail-safe net since pad_mode.ts's similar pattern also relies on a later event firing). Call self.updateNumberOfOnlineUsers() at the end of init() once the DOM node exists, so the initial badge digit ships with its label. Refs #7255 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 987bb3a commit 699cf74

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

src/static/js/pad_userlist.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,17 @@ const paduserlist = (() => {
355355

356356
if ($('#online_count').length === 0) {
357357
// role="status" + aria-live="polite" announces the count when it
358-
// changes; the localized aria-label (set in updateNumberOfOnlineUsers)
359-
// turns the bare badge digit into "N connected users" so AT users
360-
// get context, not a stray "5". See ether/etherpad#7255.
358+
// changes; the localized aria-label (set by updateNumberOfOnlineUsers
359+
// below) turns the bare badge digit into "N connected users" so AT
360+
// users get context, not a stray "5". See ether/etherpad#7255.
361361
$('#editbar [data-key=showusers] > a').append(
362362
'<span id="online_count" role="status" aria-live="polite">1</span>');
363363
}
364+
// Set the initial aria-label. updateNumberOfOnlineUsers otherwise only
365+
// fires on userJoin / userLeave / status change — on a solo-author pad
366+
// those events never come, and the badge would ship to AT with no
367+
// accessible name (the regression Playwright caught on PR #7777).
368+
self.updateNumberOfOnlineUsers();
364369

365370
$('#otheruserstable tr').remove();
366371

src/tests/frontend-new/specs/a11y_dialogs.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,13 @@ test('online_count badge has a localized accessible label (#7255)', async ({page
205205
const badge = page.locator('#online_count');
206206
await expect(badge).toHaveAttribute('role', 'status');
207207
await expect(badge).toHaveAttribute('aria-live', 'polite');
208-
// toHaveText polls so the assertion survives the initial userlist update
209-
// that pad_userlist.ts schedules after the connection completes.
208+
// toHaveText / toHaveAttribute poll so the assertions survive the
209+
// initial userlist init() pass (which appends the span and then sets
210+
// its aria-label asynchronously after html10n + setMyUserInfo land).
210211
await expect(badge).toHaveText(/^\d+$/);
211-
const label = await badge.getAttribute('aria-label');
212-
expect(label).toBeTruthy();
213212
// English plural form contains "connected user" — covers both singular
214213
// and plural without baking the exact count into the test.
215-
expect(label).toMatch(/connected user/);
214+
await expect(badge).toHaveAttribute('aria-label', /connected user/);
216215
});
217216

218217
test('linemetricsdiv is hidden from screen readers (#7255)', async ({page}) => {

0 commit comments

Comments
 (0)