Skip to content

Commit 727ebc0

Browse files
authored
SCM - add aria label to the SCMInputWidget (microsoft#239222)
1 parent eb6527c commit 727ebc0

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ import { OpenScmGroupAction } from '../../multiDiffEditor/browser/scmMultiDiffSo
102102
import { ContentHoverController } from '../../../../editor/contrib/hover/browser/contentHoverController.js';
103103
import { GlyphHoverController } from '../../../../editor/contrib/hover/browser/glyphHoverController.js';
104104
import { ITextModel } from '../../../../editor/common/model.js';
105-
import { autorun } from '../../../../base/common/observable.js';
105+
import { autorun, runOnChange } from '../../../../base/common/observable.js';
106106
import { PlaceholderTextContribution } from '../../../../editor/contrib/placeholderText/browser/placeholderTextContribution.js';
107107
import { observableConfigValue } from '../../../../platform/observable/common/platformObservableUtils.js';
108108
import { AccessibilityVerbositySettingId } from '../../accessibility/browser/accessibilityConfiguration.js';
@@ -927,8 +927,8 @@ export class SCMAccessibilityProvider implements IListAccessibilityProvider<Tree
927927

928928
const kbLabel = this.keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibilityHelp)?.getLabel();
929929
return kbLabel
930-
? localize('scmInput.accessibilityHelp', "Source Control Input, Use {0} to open Source Control Accessibility Help.", kbLabel)
931-
: localize('scmInput.accessibilityHelpNoKb', "Source Control Input, Run the Open Accessibility Help command for more information.");
930+
? localize('scmInputRow.accessibilityHelp', "Source Control Input, Use {0} to open Source Control Accessibility Help.", kbLabel)
931+
: localize('scmInputRow.accessibilityHelpNoKb', "Source Control Input, Run the Open Accessibility Help command for more information.");
932932
} else if (isSCMActionButton(element)) {
933933
return element.button?.command.title ?? '';
934934
} else if (isSCMResourceGroup(element)) {
@@ -1686,16 +1686,46 @@ class SCMInputWidget {
16861686
triggerValidation();
16871687
}));
16881688

1689-
// Update placeholder text
1690-
const updatePlaceholderText = () => {
1689+
// Aria label & placeholder text
1690+
const accessibilityVerbosityConfig = observableConfigValue(
1691+
AccessibilityVerbositySettingId.SourceControl, true, this.configurationService);
1692+
1693+
const getAriaLabel = (placeholder: string, verbosity?: boolean) => {
1694+
verbosity = verbosity ?? accessibilityVerbosityConfig.get();
1695+
1696+
if (!verbosity || !this.accessibilityService.isScreenReaderOptimized()) {
1697+
return placeholder;
1698+
}
1699+
1700+
const kbLabel = this.keybindingService.lookupKeybinding(AccessibilityCommandId.OpenAccessibilityHelp)?.getLabel();
1701+
return kbLabel
1702+
? localize('scmInput.accessibilityHelp', "{0}, Use {1} to open Source Control Accessibility Help.", placeholder, kbLabel)
1703+
: localize('scmInput.accessibilityHelpNoKb', "{0}, Run the Open Accessibility Help command for more information.", placeholder);
1704+
};
1705+
1706+
const getPlaceholderText = (): string => {
16911707
const binding = this.keybindingService.lookupKeybinding('scm.acceptInput');
16921708
const label = binding ? binding.getLabel() : (platform.isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter');
1693-
const placeholderText = format(input.placeholder, label);
1709+
return format(input.placeholder, label);
1710+
};
16941711

1695-
this.inputEditor.updateOptions({ placeholder: placeholderText });
1712+
const updatePlaceholderText = () => {
1713+
const placeholder = getPlaceholderText();
1714+
const ariaLabel = getAriaLabel(placeholder);
1715+
1716+
this.inputEditor.updateOptions({ ariaLabel, placeholder });
16961717
};
1718+
16971719
this.repositoryDisposables.add(input.onDidChangePlaceholder(updatePlaceholderText));
16981720
this.repositoryDisposables.add(this.keybindingService.onDidUpdateKeybindings(updatePlaceholderText));
1721+
1722+
this.repositoryDisposables.add(runOnChange(accessibilityVerbosityConfig, verbosity => {
1723+
const placeholder = getPlaceholderText();
1724+
const ariaLabel = getAriaLabel(placeholder, verbosity);
1725+
1726+
this.inputEditor.updateOptions({ ariaLabel });
1727+
}));
1728+
16991729
updatePlaceholderText();
17001730

17011731
// Update input template
@@ -1769,6 +1799,7 @@ class SCMInputWidget {
17691799
@ISCMViewService private readonly scmViewService: ISCMViewService,
17701800
@IContextViewService private readonly contextViewService: IContextViewService,
17711801
@IOpenerService private readonly openerService: IOpenerService,
1802+
@IAccessibilityService private readonly accessibilityService: IAccessibilityService
17721803
) {
17731804
this.element = append(container, $('.scm-editor'));
17741805
this.editorContainer = append(this.element, $('.scm-editor-container'));

0 commit comments

Comments
 (0)