Skip to content

Commit

Permalink
always set aria-selected, even for listbox
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Jan 12, 2022
1 parent 00de2f1 commit 1356392
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/vs/base/browser/ui/list/listWidget.ts
Expand Up @@ -196,19 +196,17 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {

class SelectionTrait<T> extends Trait<T> {

constructor(private setAriaSelected: boolean) {
constructor() {
super('selected');
}

override renderIndex(index: number, container: HTMLElement): void {
super.renderIndex(index, container);

if (this.setAriaSelected) {
if (this.contains(index)) {
container.setAttribute('aria-selected', 'true');
} else {
container.setAttribute('aria-selected', 'false');
}
if (this.contains(index)) {
container.setAttribute('aria-selected', 'true');
} else {
container.setAttribute('aria-selected', 'false');
}
}
}
Expand Down Expand Up @@ -1317,7 +1315,7 @@ export class List<T> implements ISpliceable<T>, IThemable, IDisposable {
private _options: IListOptions<T> = DefaultOptions
) {
const role = this._options.accessibilityProvider && this._options.accessibilityProvider.getWidgetRole ? this._options.accessibilityProvider?.getWidgetRole() : 'list';
this.selection = new SelectionTrait(role !== 'listbox');
this.selection = new SelectionTrait();

mixin(_options, defaultStyles, false);

Expand Down

0 comments on commit 1356392

Please sign in to comment.