diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts index 9bfdc3bc400250261fcd42b506d45e5155698874..a1369c06893928c3865f6d037cba26fedfcc0919 100644 --- a/src/vs/base/browser/ui/list/listWidget.ts +++ b/src/vs/base/browser/ui/list/listWidget.ts @@ -187,14 +187,16 @@ class Trait implements ISpliceable, IDisposable { class FocusTrait extends Trait { constructor( - private getDomId: IIdentityProvider + private getDomId: IIdentityProvider, + private ariaRole: string ) { super('focused'); } renderIndex(index: number, container: HTMLElement): void { super.renderIndex(index, container); - container.setAttribute('role', 'treeitem'); + + container.setAttribute('role', this.ariaRole || 'treeitem'); container.setAttribute('id', this.getDomId(index)); if (this.contains(index)) { @@ -901,7 +903,7 @@ export class List implements ISpliceable, IDisposable { renderers: IRenderer[], options: IListOptions = DefaultOptions ) { - this.focus = new FocusTrait(i => this.getElementDomId(i)); + this.focus = new FocusTrait(i => this.getElementDomId(i), options.ariaRole); this.selection = new Trait('selected'); mixin(options, defaultStyles, false); @@ -950,9 +952,6 @@ export class List implements ISpliceable, IDisposable { if (options.ariaLabel) { this.view.domNode.setAttribute('aria-label', localize('aria list', "{0}. Use the navigation keys to navigate.", options.ariaLabel)); } - if (options.ariaRole) { - this.view.domNode.setAttribute('role', options.ariaRole); - } this.style(options); }