Skip to content

Commit bec49ce

Browse files
committed
notifications - set aria label of toasts to match as if it was focused (fix microsoft#135638)
1 parent 7ca8b0f commit bec49ce

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/vs/workbench/browser/parts/notifications/notificationsCenter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ export class NotificationsCenter extends Themable implements INotificationsCente
157157
notificationsToolBar.push(hideAllAction, { icon: true, label: false, keybinding: this.getKeybindingLabel(hideAllAction) });
158158

159159
// Notifications List
160-
this.notificationsList = this.instantiationService.createInstance(NotificationsList, this.notificationsCenterContainer, {});
160+
this.notificationsList = this.instantiationService.createInstance(NotificationsList, this.notificationsCenterContainer, {
161+
widgetAriaLabel: localize('notificationsCenterWidgetAriaLabel', "Notifications Center")
162+
});
161163
this.container.appendChild(this.notificationsCenterContainer);
162164
}
163165

src/vs/workbench/browser/parts/notifications/notificationsList.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
2020
import { assertIsDefined, assertAllDefined } from 'vs/base/common/types';
2121
import { Codicon } from 'vs/base/common/codicons';
2222

23+
export interface INotificationsListOptions extends IListOptions<INotificationViewItem> {
24+
widgetAriaLabel?: string;
25+
}
26+
2327
export class NotificationsList extends Themable {
28+
2429
private listContainer: HTMLElement | undefined;
2530
private list: WorkbenchList<INotificationViewItem> | undefined;
2631
private listDelegate: NotificationsListDelegate | undefined;
@@ -29,7 +34,7 @@ export class NotificationsList extends Themable {
2934

3035
constructor(
3136
private readonly container: HTMLElement,
32-
private readonly options: IListOptions<INotificationViewItem>,
37+
private readonly options: INotificationsListOptions,
3338
@IInstantiationService private readonly instantiationService: IInstantiationService,
3439
@IThemeService themeService: IThemeService,
3540
@IContextMenuService private readonly contextMenuService: IContextMenuService
@@ -75,14 +80,15 @@ export class NotificationsList extends Themable {
7580

7681
// List
7782
const listDelegate = this.listDelegate = new NotificationsListDelegate(this.listContainer);
83+
const options = this.options;
7884
const list = this.list = <WorkbenchList<INotificationViewItem>>this._register(this.instantiationService.createInstance(
7985
WorkbenchList,
8086
'NotificationsList',
8187
this.listContainer,
8288
listDelegate,
8389
[renderer],
8490
{
85-
...this.options,
91+
...options,
8692
setRowLineHeight: false,
8793
horizontalScrolling: false,
8894
overrideStyles: {
@@ -97,7 +103,7 @@ export class NotificationsList extends Themable {
97103
return localize('notificationWithSourceAriaLabel', "{0}, source: {1}, notification", element.message.raw, element.source);
98104
},
99105
getWidgetAriaLabel(): string {
100-
return localize('notificationsList', "Notifications List");
106+
return options.widgetAriaLabel ?? localize('notificationsList', "Notifications List");
101107
},
102108
getRole(): string {
103109
return 'dialog'; // https://github.com/microsoft/vscode/issues/82728

src/vs/workbench/browser/parts/notifications/notificationsToasts.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import 'vs/css!./media/notificationsToasts';
7+
import { localize } from 'vs/nls';
78
import { INotificationsModel, NotificationChangeType, INotificationChangeEvent, INotificationViewItem, NotificationViewItemContentChangeKind } from 'vs/workbench/common/notifications';
89
import { IDisposable, dispose, toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
910
import { isAncestor, addDisposableListener, EventType, Dimension, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
@@ -183,7 +184,14 @@ export class NotificationsToasts extends Themable implements INotificationsToast
183184

184185
// Create toast with item and show
185186
const notificationList = this.instantiationService.createInstance(NotificationsList, notificationToast, {
186-
verticalScrollMode: ScrollbarVisibility.Hidden
187+
verticalScrollMode: ScrollbarVisibility.Hidden,
188+
widgetAriaLabel: (() => {
189+
if (!item.source) {
190+
return localize('notificationAriaLabel', "{0}, notification", item.message.raw);
191+
}
192+
193+
return localize('notificationWithSourceAriaLabel', "{0}, source: {1}, notification", item.message.raw, item.source);
194+
})()
187195
});
188196
itemDisposables.add(notificationList);
189197

0 commit comments

Comments
 (0)