From d177accceea386364016bcb3cc3d7539f582f876 Mon Sep 17 00:00:00 2001 From: Jason Lin Date: Fri, 2 Dec 2022 18:17:57 +1100 Subject: [PATCH] Fix a11y issues #4269 --- src/browser/AccessibilityManager.ts | 5 ++++- src/browser/Terminal.ts | 14 +++++++++----- src/common/Platform.ts | 2 ++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/browser/AccessibilityManager.ts b/src/browser/AccessibilityManager.ts index 3998e77928..49e4c66b1a 100644 --- a/src/browser/AccessibilityManager.ts +++ b/src/browser/AccessibilityManager.ts @@ -246,7 +246,10 @@ export class AccessibilityManager extends Disposable { private _handleKey(keyChar: string): void { this._clearLiveRegion(); - this._charsToConsume.push(keyChar); + // Only add the char if there is no control character. + if (!/\p{Control}/u.test(keyChar)) { + this._charsToConsume.push(keyChar); + } } private _refreshRows(start?: number, end?: number): void { diff --git a/src/browser/Terminal.ts b/src/browser/Terminal.ts index 3c88b94816..caeec050b9 100644 --- a/src/browser/Terminal.ts +++ b/src/browser/Terminal.ts @@ -445,7 +445,11 @@ export class Terminal extends CoreTerminal implements ITerminal { this.textarea = document.createElement('textarea'); this.textarea.classList.add('xterm-helper-textarea'); this.textarea.setAttribute('aria-label', Strings.promptLabel); - this.textarea.setAttribute('aria-multiline', 'false'); + if (!Browser.isChromeOS) { + // ChromeVox on ChromeOS does not like this. See + // https://issuetracker.google.com/issues/260170397 + this.textarea.setAttribute('aria-multiline', 'false'); + } this.textarea.setAttribute('autocorrect', 'off'); this.textarea.setAttribute('autocapitalize', 'off'); this.textarea.setAttribute('spellcheck', 'false'); @@ -1057,10 +1061,10 @@ export class Terminal extends CoreTerminal implements ITerminal { this.coreService.triggerDataEvent(result.key, true); // Cancel events when not in screen reader mode so events don't get bubbled up and handled by - // other listeners. When screen reader mode is enabled, this could cause issues if the event - // is handled at a higher level, this is a compromise in order to echo keys to the screen - // reader. - if (!this.optionsService.rawOptions.screenReaderMode) { + // other listeners. When screen reader mode is enabled, we don't cancel them (unless ctrl or alt + // is also depressed) so that the cursor textarea can be updated, which triggers the screen + // reader to read it. + if (!this.optionsService.rawOptions.screenReaderMode || event.altKey || event.ctrlKey) { return this.cancel(event, true); } diff --git a/src/common/Platform.ts b/src/common/Platform.ts index 034665cd25..41d8552e49 100644 --- a/src/common/Platform.ts +++ b/src/common/Platform.ts @@ -39,3 +39,5 @@ export const isIpad = platform === 'iPad'; export const isIphone = platform === 'iPhone'; export const isWindows = ['Windows', 'Win16', 'Win32', 'WinCE'].includes(platform); export const isLinux = platform.indexOf('Linux') >= 0; +// Note that when this is true, isLinux will also be true. +export const isChromeOS = /\bCrOS\b/.test(userAgent);