Skip to content

Commit

Permalink
list: only aria-selected on selected items
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Mar 6, 2020
1 parent 435048b commit 55c2dc5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/vs/base/browser/ui/list/listWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {
}
}

class FocusTrait<T> extends Trait<T> {
class SelectionTrait<T> extends Trait<T> {

constructor(private isAriaSelected: (index: number) => boolean) {
super('focused');
constructor() {
super('selected');
}

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

if (this.contains(index) || this.isAriaSelected(index)) {
if (this.contains(index)) {
container.setAttribute('aria-selected', 'true');
} else {
container.setAttribute('aria-selected', 'false');
Expand Down Expand Up @@ -1198,8 +1198,8 @@ export class List<T> implements ISpliceable<T>, IDisposable {
renderers: IListRenderer<any /* TODO@joao */, any>[],
private _options: IListOptions<T> = DefaultOptions
) {
this.selection = new Trait('selected');
this.focus = new FocusTrait(this.selection.contains);
this.selection = new SelectionTrait();
this.focus = new Trait('focused');

mixin(_options, defaultStyles, false);

Expand Down

0 comments on commit 55c2dc5

Please sign in to comment.