Skip to content

Commit 4dbe013

Browse files
Use setTimeout0 to defer setting Count til element is fully shown for now (#270825)
This is a workaround for now for an accessibility bug that should be addressed. The way that the checked count works is that it's a `CountBadge` widget wrapped in an `aria-live` that reports when the text content (aka the number) changes. However, when the QuickPick is initially shown to the user, the resolved count is done so before actually made visible... `aria-live` does not read out anything that is changed when hidden. I think a proper change here would be to have a separate `aria-live` element that is always off screen (so "technically" visible)... that can be updated when a Count is made visible... but this small fix is fine to at least give screen reader users a count. Fixes #258617
1 parent ca9fa4f commit 4dbe013

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { autorun, observableValue } from '../../../base/common/observable.js';
2929
import { StandardMouseEvent } from '../../../base/browser/mouseEvent.js';
3030
import { IStorageService, StorageScope, StorageTarget } from '../../storage/common/storage.js';
3131
import { IConfigurationService } from '../../configuration/common/configuration.js';
32-
import { Platform, platform } from '../../../base/common/platform.js';
32+
import { Platform, platform, setTimeout0 } from '../../../base/common/platform.js';
3333
import { getWindowControlsStyle, WindowControlsStyle } from '../../window/common/window.js';
3434
import { getZoomFactor } from '../../../base/browser/browser.js';
3535
import { TriStateCheckbox } from '../../../base/browser/ui/toggle/toggle.js';
@@ -227,7 +227,10 @@ export class QuickInputController extends Disposable {
227227
visibleCount.setCount(c);
228228
}));
229229
this._register(list.onChangedCheckedCount(c => {
230-
count.setCount(c);
230+
// TODO@TylerLeonhardt: Without this setTimeout, the screen reader will not read out
231+
// the final count of checked items correctly. Investigate a better way
232+
// to do this. ref https://github.com/microsoft/vscode/issues/258617
233+
setTimeout0(() => count.setCount(c));
231234
}));
232235
this._register(list.onLeave(() => {
233236
// Defer to avoid the input field reacting to the triggering key.

src/vs/platform/quickinput/browser/tree/quickTree.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { Emitter, Event } from '../../../../base/common/event.js';
77
import { autorun, IReader, observableValue } from '../../../../base/common/observable.js';
8+
import { setTimeout0 } from '../../../../base/common/platform.js';
89
import { localize } from '../../../../nls.js';
910
import { IQuickTree, IQuickTreeItem, IQuickTreeItemButtonEvent, QuickInputType, QuickPickFocus } from '../../common/quickInput.js';
1011
import { QuickInput, QuickInputUI, Visibilities } from '../quickInput.js';
@@ -135,7 +136,10 @@ export class QuickTree<T extends IQuickTreeItem> extends QuickInput implements I
135136
super.show(); // TODO: Why have show() bubble up while update() trickles down?
136137

137138
// Intial state
138-
this.ui.count.setCount(this.ui.tree.getCheckedLeafItems().length);
139+
// TODO@TylerLeonhardt: Without this setTimeout, the screen reader will not read out
140+
// the final count of checked items correctly. Investigate a better way
141+
// to do this. ref https://github.com/microsoft/vscode/issues/258617
142+
setTimeout0(() => this.ui.count.setCount(this.ui.tree.getCheckedLeafItems().length));
139143
const checkAllState = getParentNodeState([...this.ui.tree.tree.getNode().children]);
140144
if (this.ui.checkAll.checked !== checkAllState) {
141145
this.ui.checkAll.checked = checkAllState;

0 commit comments

Comments
 (0)