Skip to content

Commit

Permalink
fix #187114
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Jul 13, 2023
1 parent 29f0271 commit 02447a5
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 33 deletions.
13 changes: 7 additions & 6 deletions src/vs/workbench/browser/accessibility/accessibleView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,20 @@ class AccessibleView extends Disposable {
});
const disposableStore = new DisposableStore();
disposableStore.add(this._editorWidget.onKeyUp((e) => {
if (e.keyCode === KeyCode.Escape) {
this._contextViewService.hideContextView();
// Delay to allow the context view to hide #186514
setTimeout(() => provider.onClose(), 100);
} else if (e.keyCode === KeyCode.KeyD && this._configurationService.getValue(settingKey)) {
if (e.keyCode === KeyCode.KeyD && this._configurationService.getValue(settingKey)) {
alert(localize('disableAccessibilityHelp', '{0} accessibility verbosity is now disabled', provider.verbositySettingKey));
this._configurationService.updateValue(settingKey, false);
}
e.stopPropagation();
provider.onKeyDown?.(e);
}));
disposableStore.add(this._editorWidget.onKeyDown((e) => {
if (e.keyCode === KeyCode.KeyH && provider.options.readMoreUrl) {
if (e.keyCode === KeyCode.Escape) {
e.stopPropagation();
this._contextViewService.hideContextView();
// Delay to allow the context view to hide #186514
setTimeout(() => provider.onClose(), 100);
} else if (e.keyCode === KeyCode.KeyH && provider.options.readMoreUrl) {
const url: string = provider.options.readMoreUrl!;
alert(AccessibilityHelpNLS.openingDocs);
this._openerService.open(URI.parse(url));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ export interface INotificationsToastController {
hide(): void;
}

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

function getNotificationFromContext(listService: IListService, context?: unknown): INotificationViewItem | undefined {
if (isNotificationViewItem(context)) {
return context;
const list = listService.lastFocusedList;
if (list instanceof WorkbenchList) {
const focusedElement = list.getFocusedElements()[0];
if (isNotificationViewItem(focusedElement)) {
return focusedElement;
}
}

const list = listService.lastFocusedList;
if (list instanceof WorkbenchList) {
const focusedElement = list.getFocusedElements()[0];
if (isNotificationViewItem(focusedElement)) {
return focusedElement;
}
}
return undefined;
}

return undefined;
}
export function registerNotificationCommands(center: INotificationsCenterController, toasts: INotificationsToastController, model: NotificationsModel): void {

// Show Notifications Cneter
CommandsRegistry.registerCommand(SHOW_NOTIFICATIONS_CENTER, () => {
Expand Down
16 changes: 2 additions & 14 deletions src/vs/workbench/browser/parts/notifications/notificationsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { NotificationFocusedContext } from 'vs/workbench/common/contextkeys';
import { Disposable } from 'vs/base/common/lifecycle';
import { AriaRole } from 'vs/base/browser/ui/aria/aria';
import { NotificationActionRunner } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
import { AccessibleViewType, IAccessibleViewService } from 'vs/workbench/browser/accessibility/accessibleView';

export interface INotificationsListOptions extends IListOptions<INotificationViewItem> {
readonly widgetAriaLabel?: string;
Expand All @@ -37,8 +36,7 @@ export class NotificationsList extends Disposable {
private readonly container: HTMLElement,
private readonly options: INotificationsListOptions,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IAccessibleViewService private readonly accessibleViewService: IAccessibleViewService
@IContextMenuService private readonly contextMenuService: IContextMenuService
) {
super();
}
Expand Down Expand Up @@ -163,17 +161,7 @@ export class NotificationsList extends Disposable {
// Remember focus and relative top of that item
const focusedIndex = list.getFocus()[0];
const focusedItem = this.viewModel[focusedIndex];
this.accessibleViewService.show({
provideContent: () => { return focusedItem.message.original.toString() || ''; },
onClose(): void {
list.setFocus([focusedIndex]);
},
verbositySettingKey: 'notifications',
options: {
ariaLabel: localize('notification', "Notification Accessible View"),
type: AccessibleViewType.View
}
});

let focusRelativeTop: number | null = null;
if (typeof focusedIndex === 'number') {
focusRelativeTop = list.getRelativeTop(focusedIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import { NEW_UNTITLED_FILE_COMMAND_ID } from 'vs/workbench/contrib/files/browser
import { ModesHoverController } from 'vs/editor/contrib/hover/browser/hover';
import { withNullAsUndefined } from 'vs/base/common/types';
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
import { getNotificationFromContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
import { IListService, WorkbenchList } from 'vs/platform/list/browser/listService';
import { NotificationFocusedContext } from 'vs/workbench/common/contextkeys';

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


class NotificationAccessibleViewContribution extends Disposable {
static ID: 'notificationAccessibleViewContribution';
constructor() {
super();
this._register(AccessibleViewAction.addImplementation(90, 'notifications', accessor => {
const accessibleViewService = accessor.get(IAccessibleViewService);
const listService = accessor.get(IListService);
const notification = getNotificationFromContext(listService);
if (!notification) {
return false;
}
let notificationIndex: number | undefined;
const list = listService.lastFocusedList;
if (list instanceof WorkbenchList) {
notificationIndex = list.indexOf(notification);
}
if (notificationIndex === undefined) {
return false;
}
accessibleViewService.show({
provideContent: () => { return notification.message.original.toString() || ''; },
onClose(): void {
if (list && notificationIndex !== undefined) {
list.domFocus();
list.setFocus([notificationIndex]);
}
},
verbositySettingKey: 'notifications',
options: {
ariaLabel: localize('notification', "Notification Accessible View"),
type: AccessibleViewType.View
}
});
return true;
}, NotificationFocusedContext));
}
}

workbenchContributionsRegistry.registerWorkbenchContribution(NotificationAccessibleViewContribution, LifecyclePhase.Eventually);

0 comments on commit 02447a5

Please sign in to comment.