Skip to content

Commit c74ab84

Browse files
Remove aria-activedescendant when typing & remove clearFocus code (#239857)
This applies some good feedback from @rperez030 in here: #237324 (comment) which gave me the idea to just remove `aria-activedescendant` whenever you type in the input box. This allows arrow keys and selections to read out. Because of that, we can remove this SHIFT+TAB behavior I introduced a while back since that isn't needed to get the screen reader to read out the arrow keys. Note: deletions in certain quick picks remain a challenge. Since deletion leads to a changed filter, which triggers the list to highlight something new, often deletions are overriden by the list changes. Honestly, even the SHIFT+TAB behavior before didn't improve the deletions... sometimes the screen reader read them, sometimes it didn't. Fixes #180862
1 parent 3108f00 commit c74ab84

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/vs/platform/quickinput/browser/quickInputBox.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as dom from '../../../base/browser/dom.js';
7-
import { StandardKeyboardEvent } from '../../../base/browser/keyboardEvent.js';
8-
import { StandardMouseEvent } from '../../../base/browser/mouseEvent.js';
97
import { FindInput } from '../../../base/browser/ui/findinput/findInput.js';
108
import { IInputBoxStyles, IRange, MessageType } from '../../../base/browser/ui/inputbox/inputBox.js';
119
import { IToggleStyles, Toggle } from '../../../base/browser/ui/toggle/toggle.js';
@@ -34,13 +32,13 @@ export class QuickInputBox extends Disposable {
3432
input.ariaAutoComplete = 'list';
3533
}
3634

37-
onKeyDown = (handler: (event: StandardKeyboardEvent) => void): IDisposable => {
38-
return dom.addStandardDisposableListener(this.findInput.inputBox.inputElement, dom.EventType.KEY_DOWN, handler);
39-
};
35+
get onKeyDown() {
36+
return this.findInput.onKeyDown;
37+
}
4038

41-
onMouseDown = (handler: (event: StandardMouseEvent) => void): IDisposable => {
42-
return dom.addStandardDisposableListener(this.findInput.inputBox.inputElement, dom.EventType.MOUSE_DOWN, handler);
43-
};
39+
get onMouseDown() {
40+
return this.findInput.onMouseDown;
41+
}
4442

4543
onDidChange = (handler: (event: string) => void): IDisposable => {
4644
return this.findInput.onDidChange(handler);

src/vs/platform/quickinput/browser/quickInputController.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ export class QuickInputController extends Disposable {
262262
if (this.endOfQuickInputBoxContext.get() !== value) {
263263
this.endOfQuickInputBoxContext.set(value);
264264
}
265+
// Allow screenreaders to read what's in the input
266+
// Note: this works for arrow keys and selection changes,
267+
// but not for deletions since that often triggers a
268+
// change in the list.
269+
inputBox.removeAttribute('aria-activedescendant');
265270
}));
266271
this._register(dom.addDisposableListener(container, dom.EventType.FOCUS, (e: FocusEvent) => {
267272
inputBox.setFocus();
@@ -313,15 +318,14 @@ export class QuickInputController extends Disposable {
313318
selectors.push('.quick-input-html-widget');
314319
}
315320
const stops = container.querySelectorAll<HTMLElement>(selectors.join(', '));
316-
if (event.shiftKey && event.target === stops[0]) {
317-
// Clear the focus from the list in order to allow
318-
// screen readers to read operations in the input box.
319-
dom.EventHelper.stop(event, true);
320-
list.clearFocus();
321-
} else if (!event.shiftKey && dom.isAncestor(event.target, stops[stops.length - 1])) {
321+
if (!event.shiftKey && dom.isAncestor(event.target, stops[stops.length - 1])) {
322322
dom.EventHelper.stop(event, true);
323323
stops[0].focus();
324324
}
325+
if (event.shiftKey && dom.isAncestor(event.target, stops[0])) {
326+
dom.EventHelper.stop(event, true);
327+
stops[stops.length - 1].focus();
328+
}
325329
}
326330
break;
327331
}

0 commit comments

Comments
 (0)