Skip to content

Commit 4740213

Browse files
committed
list: improve aria-selected to be set on each selected element. Set aria-multiselectable when mutli selct is supported
1 parent 43f8140 commit 4740213

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/vs/base/browser/ui/list/listWidget.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {
180180
}
181181
}
182182

183-
class FocusTrait<T> extends Trait<T> {
183+
class SelectionTrait<T> extends Trait<T> {
184184

185185
constructor() {
186-
super('focused');
186+
super('selected');
187187
}
188188

189189
renderIndex(index: number, container: HTMLElement): void {
@@ -1198,8 +1198,8 @@ export class List<T> implements ISpliceable<T>, IDisposable {
11981198
renderers: IListRenderer<any /* TODO@joao */, any>[],
11991199
private _options: IListOptions<T> = DefaultOptions
12001200
) {
1201-
this.focus = new FocusTrait();
1202-
this.selection = new Trait('selected');
1201+
this.focus = new Trait('focused');
1202+
this.selection = new SelectionTrait();
12031203

12041204
mixin(_options, defaultStyles, false);
12051205

@@ -1272,6 +1272,9 @@ export class List<T> implements ISpliceable<T>, IDisposable {
12721272
if (_options.ariaLabel) {
12731273
this.view.domNode.setAttribute('aria-label', localize('aria list', "{0}. Use the navigation keys to navigate.", _options.ariaLabel));
12741274
}
1275+
if (_options.multipleSelectionSupport) {
1276+
this.view.domNode.setAttribute('aria-multiselectable', 'true');
1277+
}
12751278
}
12761279

12771280
protected createMouseController(options: IListOptions<T>): MouseController<T> {

src/vs/base/parts/tree/browser/treeView.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,15 @@ export class ViewItem implements IViewItem {
218218
}
219219
if (this.model.hasTrait('focused')) {
220220
const base64Id = strings.safeBtoa(this.model.id);
221-
222-
this.element.setAttribute('aria-selected', 'true');
223221
this.element.setAttribute('id', base64Id);
224222
} else {
225-
this.element.setAttribute('aria-selected', 'false');
226223
this.element.removeAttribute('id');
227224
}
225+
if (this.model.hasTrait('selected')) {
226+
this.element.setAttribute('aria-selected', 'true');
227+
} else {
228+
this.element.setAttribute('aria-selected', 'false');
229+
}
228230
if (this.model.hasChildren()) {
229231
this.element.setAttribute('aria-expanded', String(!!this._styles['expanded']));
230232
} else {

0 commit comments

Comments
 (0)