Skip to content

Commit

Permalink
Merge pull request #182324 from microsoft/merogge/acc-edit
Browse files Browse the repository at this point in the history
use `editMode:preview` by default for screen reader users
  • Loading branch information
meganrogge committed May 15, 2023
2 parents c0377b2 + c59162e commit e14e406
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { IEditorWorkerService } from 'vs/editor/common/services/editorWorker';
import { IModelService } from 'vs/editor/common/services/model';
import { InlineCompletionsController } from 'vs/editor/contrib/inlineCompletions/browser/inlineCompletionsController';
import { localize } from 'vs/nls';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
Expand Down Expand Up @@ -105,6 +106,7 @@ export class InteractiveEditorController implements IEditorContribution {
@INotebookEditorService private readonly _notebookEditorService: INotebookEditorService,
@IDialogService private readonly _dialogService: IDialogService,
@IContextKeyService contextKeyService: IContextKeyService,
@IAccessibilityService private readonly _accessibilityService: IAccessibilityService
) {
this._ctxHasActiveRequest = CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST.bindTo(contextKeyService);
this._ctxLastEditKind = CTX_INTERACTIVE_EDITOR_LAST_EDIT_KIND.bindTo(contextKeyService);
Expand Down Expand Up @@ -137,6 +139,17 @@ export class InteractiveEditorController implements IEditorContribution {
return INTERACTIVE_EDITOR_ID;
}

private _getMode(): EditMode {
let editMode: EditMode = this._configurationService.getValue('interactiveEditor.editMode');
const isDefault = editMode === EditMode.LivePreview;
if (this._accessibilityService.isScreenReaderOptimized() && isDefault) {
// By default, use preview mode for screen reader users
editMode = EditMode.Preview;
this._configurationService.updateValue('interactiveEditor.editMode', EditMode.Preview);
}
return editMode;
}

getWidgetPosition(): Position | undefined {
return this._zone.position;
}
Expand Down Expand Up @@ -171,7 +184,7 @@ export class InteractiveEditorController implements IEditorContribution {

session = await this._interactiveEditorSessionService.createSession(
this._editor,
{ editMode: this._configurationService.getValue('interactiveEditor.editMode'), wholeRange: options?.initialRange },
{ editMode: this._getMode(), wholeRange: options?.initialRange },
createSessionCts.token
);

Expand Down

0 comments on commit e14e406

Please sign in to comment.