Skip to content

Commit

Permalink
Merge pull request #209270 from microsoft/merogge/qp-bug
Browse files Browse the repository at this point in the history
fix accessibility signal qp bug
  • Loading branch information
meganrogge authored Apr 1, 2024
2 parents 7733a6a + 3dc6e72 commit e4f949b
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/vs/workbench/contrib/accessibilitySignals/browser/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ export class ShowSignalSoundHelp extends Action2 {
configurationService.updateValue(signal.settingsKey, { sound });
}
}

for (const signal of disabledSounds) {
let { sound, announcement } = configurationService.getValue<{ sound: string; announcement?: string }>(signal.settingsKey);
sound = userGestureSignals.includes(signal) ? 'never' : 'off';
if (announcement) {
configurationService.updateValue(signal.settingsKey, { sound, announcement });
} else {
configurationService.updateValue(signal.settingsKey, { sound });
}
const announcement = configurationService.getValue(signal.settingsKey + '.announcement');
const sound = getDisabledSettingValue(userGestureSignals.includes(signal), accessibilityService.isScreenReaderOptimized());
const value = announcement ? { sound, announcement } : { sound };
configurationService.updateValue(signal.settingsKey, value);
}
qp.hide();
});
Expand All @@ -82,6 +80,10 @@ export class ShowSignalSoundHelp extends Action2 {
}
}

function getDisabledSettingValue(isUserGestureSignal: boolean, isScreenReaderOptimized: boolean): string {
return isScreenReaderOptimized ? (isUserGestureSignal ? 'never' : 'off') : (isUserGestureSignal ? 'never' : 'auto');
}

export class ShowAccessibilityAnnouncementHelp extends Action2 {
static readonly ID = 'accessibility.announcement.help';

Expand Down Expand Up @@ -115,25 +117,33 @@ export class ShowAccessibilityAnnouncementHelp extends Action2 {
const qp = quickInputService.createQuickPick<IQuickPickItem & { signal: AccessibilitySignal }>();
qp.items = items;
qp.selectedItems = items.filter(i => accessibilitySignalService.isAnnouncementEnabled(i.signal) || userGestureSignals.includes(i.signal) && configurationService.getValue(i.signal.settingsKey + '.announcement') !== 'never');
const screenReaderOptimized = accessibilityService.isScreenReaderOptimized();
qp.onDidAccept(() => {
if (!screenReaderOptimized) {
// announcements are off by default when screen reader is not active
qp.hide();
return;
}
const enabledAnnouncements = qp.selectedItems.map(i => i.signal);
const disabledAnnouncements = AccessibilitySignal.allAccessibilitySignals.filter(cue => !!cue.legacyAnnouncementSettingsKey && !enabledAnnouncements.includes(cue));
for (const signal of enabledAnnouncements) {
let { sound, announcement } = configurationService.getValue<{ sound: string; announcement?: string }>(signal.settingsKey);
announcement = userGestureSignals.includes(signal) ? 'userGesture' : signal.announcementMessage && accessibilityService.isScreenReaderOptimized() ? 'auto' : undefined;
configurationService.updateValue(signal.settingsKey, { sound, announcement });
}

for (const signal of disabledAnnouncements) {
const announcement = userGestureSignals.includes(signal) ? 'never' : 'off';
const announcement = getDisabledSettingValue(userGestureSignals.includes(signal), true);
const sound = configurationService.getValue(signal.settingsKey + '.sound');
configurationService.updateValue(signal.settingsKey, announcement ? { sound, announcement } : { sound });
const value = announcement ? { sound, announcement } : { sound };
configurationService.updateValue(signal.settingsKey, value);
}
qp.hide();
});
qp.onDidTriggerItemButton(e => {
preferencesService.openUserSettings({ jsonEditor: true, revealSetting: { key: e.item.signal.settingsKey, edit: true } });
});
qp.placeholder = localize('announcement.help.placeholder', 'Select an announcement to configure');
qp.placeholder = screenReaderOptimized ? localize('announcement.help.placeholder', 'Select an announcement to configure') : localize('announcement.help.placeholder.disabled', 'Screen reader is not active, announcements are disabled by default.');
qp.canSelectMany = true;
await qp.show();
}
Expand Down

0 comments on commit e4f949b

Please sign in to comment.