Skip to content

Commit 02447a5

Browse files
committed
1 parent 29f0271 commit 02447a5

File tree

4 files changed

+65
-33
lines changed

4 files changed

+65
-33
lines changed

src/vs/workbench/browser/accessibility/accessibleView.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,20 @@ class AccessibleView extends Disposable {
170170
});
171171
const disposableStore = new DisposableStore();
172172
disposableStore.add(this._editorWidget.onKeyUp((e) => {
173-
if (e.keyCode === KeyCode.Escape) {
174-
this._contextViewService.hideContextView();
175-
// Delay to allow the context view to hide #186514
176-
setTimeout(() => provider.onClose(), 100);
177-
} else if (e.keyCode === KeyCode.KeyD && this._configurationService.getValue(settingKey)) {
173+
if (e.keyCode === KeyCode.KeyD && this._configurationService.getValue(settingKey)) {
178174
alert(localize('disableAccessibilityHelp', '{0} accessibility verbosity is now disabled', provider.verbositySettingKey));
179175
this._configurationService.updateValue(settingKey, false);
180176
}
181177
e.stopPropagation();
182178
provider.onKeyDown?.(e);
183179
}));
184180
disposableStore.add(this._editorWidget.onKeyDown((e) => {
185-
if (e.keyCode === KeyCode.KeyH && provider.options.readMoreUrl) {
181+
if (e.keyCode === KeyCode.Escape) {
182+
e.stopPropagation();
183+
this._contextViewService.hideContextView();
184+
// Delay to allow the context view to hide #186514
185+
setTimeout(() => provider.onClose(), 100);
186+
} else if (e.keyCode === KeyCode.KeyH && provider.options.readMoreUrl) {
186187
const url: string = provider.options.readMoreUrl!;
187188
alert(AccessibilityHelpNLS.openingDocs);
188189
this._openerService.open(URI.parse(url));

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,23 @@ export interface INotificationsToastController {
6161
hide(): void;
6262
}
6363

64-
export function registerNotificationCommands(center: INotificationsCenterController, toasts: INotificationsToastController, model: NotificationsModel): void {
64+
export function getNotificationFromContext(listService: IListService, context?: unknown): INotificationViewItem | undefined {
65+
if (isNotificationViewItem(context)) {
66+
return context;
67+
}
6568

66-
function getNotificationFromContext(listService: IListService, context?: unknown): INotificationViewItem | undefined {
67-
if (isNotificationViewItem(context)) {
68-
return context;
69+
const list = listService.lastFocusedList;
70+
if (list instanceof WorkbenchList) {
71+
const focusedElement = list.getFocusedElements()[0];
72+
if (isNotificationViewItem(focusedElement)) {
73+
return focusedElement;
6974
}
75+
}
7076

71-
const list = listService.lastFocusedList;
72-
if (list instanceof WorkbenchList) {
73-
const focusedElement = list.getFocusedElements()[0];
74-
if (isNotificationViewItem(focusedElement)) {
75-
return focusedElement;
76-
}
77-
}
77+
return undefined;
78+
}
7879

79-
return undefined;
80-
}
80+
export function registerNotificationCommands(center: INotificationsCenterController, toasts: INotificationsToastController, model: NotificationsModel): void {
8181

8282
// Show Notifications Cneter
8383
CommandsRegistry.registerCommand(SHOW_NOTIFICATIONS_CENTER, () => {

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { NotificationFocusedContext } from 'vs/workbench/common/contextkeys';
1919
import { Disposable } from 'vs/base/common/lifecycle';
2020
import { AriaRole } from 'vs/base/browser/ui/aria/aria';
2121
import { NotificationActionRunner } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
22-
import { AccessibleViewType, IAccessibleViewService } from 'vs/workbench/browser/accessibility/accessibleView';
2322

2423
export interface INotificationsListOptions extends IListOptions<INotificationViewItem> {
2524
readonly widgetAriaLabel?: string;
@@ -37,8 +36,7 @@ export class NotificationsList extends Disposable {
3736
private readonly container: HTMLElement,
3837
private readonly options: INotificationsListOptions,
3938
@IInstantiationService private readonly instantiationService: IInstantiationService,
40-
@IContextMenuService private readonly contextMenuService: IContextMenuService,
41-
@IAccessibleViewService private readonly accessibleViewService: IAccessibleViewService
39+
@IContextMenuService private readonly contextMenuService: IContextMenuService
4240
) {
4341
super();
4442
}
@@ -163,17 +161,7 @@ export class NotificationsList extends Disposable {
163161
// Remember focus and relative top of that item
164162
const focusedIndex = list.getFocus()[0];
165163
const focusedItem = this.viewModel[focusedIndex];
166-
this.accessibleViewService.show({
167-
provideContent: () => { return focusedItem.message.original.toString() || ''; },
168-
onClose(): void {
169-
list.setFocus([focusedIndex]);
170-
},
171-
verbositySettingKey: 'notifications',
172-
options: {
173-
ariaLabel: localize('notification', "Notification Accessible View"),
174-
type: AccessibleViewType.View
175-
}
176-
});
164+
177165
let focusRelativeTop: number | null = null;
178166
if (typeof focusedIndex === 'number') {
179167
focusRelativeTop = list.getRelativeTop(focusedIndex);

src/vs/workbench/contrib/accessibility/browser/accessibility.contribution.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import { NEW_UNTITLED_FILE_COMMAND_ID } from 'vs/workbench/contrib/files/browser
2424
import { ModesHoverController } from 'vs/editor/contrib/hover/browser/hover';
2525
import { withNullAsUndefined } from 'vs/base/common/types';
2626
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
27+
import { getNotificationFromContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
28+
import { IListService, WorkbenchList } from 'vs/platform/list/browser/listService';
29+
import { NotificationFocusedContext } from 'vs/workbench/common/contextkeys';
2730

2831
registerAccessibilityConfiguration();
2932
registerSingleton(IAccessibleViewService, AccessibleViewService, InstantiationType.Delayed);
@@ -133,3 +136,43 @@ class HoverAccessibleViewContribution extends Disposable {
133136
const workbenchContributionsRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
134137
workbenchContributionsRegistry.registerWorkbenchContribution(HoverAccessibleViewContribution, LifecyclePhase.Eventually);
135138

139+
140+
class NotificationAccessibleViewContribution extends Disposable {
141+
static ID: 'notificationAccessibleViewContribution';
142+
constructor() {
143+
super();
144+
this._register(AccessibleViewAction.addImplementation(90, 'notifications', accessor => {
145+
const accessibleViewService = accessor.get(IAccessibleViewService);
146+
const listService = accessor.get(IListService);
147+
const notification = getNotificationFromContext(listService);
148+
if (!notification) {
149+
return false;
150+
}
151+
let notificationIndex: number | undefined;
152+
const list = listService.lastFocusedList;
153+
if (list instanceof WorkbenchList) {
154+
notificationIndex = list.indexOf(notification);
155+
}
156+
if (notificationIndex === undefined) {
157+
return false;
158+
}
159+
accessibleViewService.show({
160+
provideContent: () => { return notification.message.original.toString() || ''; },
161+
onClose(): void {
162+
if (list && notificationIndex !== undefined) {
163+
list.domFocus();
164+
list.setFocus([notificationIndex]);
165+
}
166+
},
167+
verbositySettingKey: 'notifications',
168+
options: {
169+
ariaLabel: localize('notification', "Notification Accessible View"),
170+
type: AccessibleViewType.View
171+
}
172+
});
173+
return true;
174+
}, NotificationFocusedContext));
175+
}
176+
}
177+
178+
workbenchContributionsRegistry.registerWorkbenchContribution(NotificationAccessibleViewContribution, LifecyclePhase.Eventually);

0 commit comments

Comments
 (0)