Skip to content

Commit feae0f9

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: announce to screen readers that the label is generating
This CL ensures that the loading status is announced to screen readers. It also fixed a bug where we were announcing selected events too eagerly even when the selection hadn't changed, and the same with empty labels. I turned on voice over and got very overwhelmed! Fixed: 407047308 Change-Id: I63abd5a16ab8147bb185ad2d853595b267a09ff5 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6415788 Reviewed-by: Alina Varkki <[email protected]> Auto-Submit: Jack Franklin <[email protected]> Commit-Queue: Jack Franklin <[email protected]>
1 parent 02606bd commit feae0f9

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

front_end/panels/timeline/AnnotationHelpers.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ describe('AnnotationHelpers', () => {
139139
assert.strictEqual(text, 'The entry label annotation has been added');
140140
});
141141

142+
it('does not return an announcement for new empty labels', async () => {
143+
const overlay: Overlays.Overlays.EntryLabel = {type: 'ENTRY_LABEL', entry: FAKE_ENTRY_1, label: ''};
144+
const event = new Timeline.ModificationsManager.AnnotationModifiedEvent(overlay, 'Add');
145+
const text = ariaAnnouncementForModifiedEvent(event);
146+
assert.isNull(text);
147+
});
148+
142149
it('returns text for an annotation having its label updated', async () => {
143150
const overlay: Overlays.Overlays.EntryLabel = {type: 'ENTRY_LABEL', entry: FAKE_ENTRY_1, label: 'Hello world'};
144151
const event = new Timeline.ModificationsManager.AnnotationModifiedEvent(overlay, 'UpdateLabel');

front_end/panels/timeline/AnnotationHelpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ export function ariaDescriptionForOverlay(overlay: Overlays.Overlays.TimelineOve
164164
return i18nString(UIStrings.entriesLink);
165165
}
166166
if (isEntryLabel(overlay)) {
167-
return i18nString(UIStrings.entryLabel);
167+
// Don't announce an empty label
168+
return overlay.label.length > 0 ? i18nString(UIStrings.entryLabel) : null;
168169
}
169170

170171
// Not an annotation overlay: ignore.

front_end/panels/timeline/TimelinePanel.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import {
7878
rangeForSelection,
7979
selectionFromEvent,
8080
selectionIsRange,
81+
selectionsEqual,
8182
type TimelineSelection,
8283
} from './TimelineSelection.js';
8384
import timelineStatusDialogStyles from './timelineStatusDialog.css.js';
@@ -2665,6 +2666,11 @@ export class TimelinePanel extends UI.Panel.Panel implements Client, TimelineMod
26652666
return;
26662667
}
26672668

2669+
if (oldSelection && selectionsEqual(oldSelection, newSelection)) {
2670+
// Don't announce to the user if the selection has not changed.
2671+
return;
2672+
}
2673+
26682674
if (selectionIsRange(newSelection)) {
26692675
// We don't announce here; within the annotations code we announce when
26702676
// the user creates a new time range selection. So if we also announce

front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ export class EntryLabelOverlay extends HTMLElement {
523523
try {
524524
// Trigger a re-render to display the loading component in the place of the button when the label is being generated.
525525
this.#isAILabelLoading = true;
526+
UI.ARIAUtils.alert(UIStringsNotTranslate.generatingLabel);
526527
// Trigger a re-render to put focus back on the input box, otherwise
527528
// when the button changes to a loading spinner, it loses focus and the
528529
// editing state is reset because the component loses focus.

0 commit comments

Comments
 (0)