Skip to content

Commit

Permalink
a18y: avoid duplicate events when navigating trees (for #26730)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored and dbaeumer committed May 26, 2017
1 parent a9486e4 commit 03284d8
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/vs/base/parts/tree/browser/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,18 @@ export class ViewItem implements IViewItem {

// ARIA
this.element.setAttribute('role', 'treeitem');
const ariaLabel = this.context.accessibilityProvider.getAriaLabel(this.context.tree, this.model.getElement());
if (ariaLabel) {
this.element.setAttribute('aria-label', ariaLabel);
}
if (this.model.hasTrait('focused')) {
const base64Id = strings.safeBtoa(this.model.id);
const ariaLabel = this.context.accessibilityProvider.getAriaLabel(this.context.tree, this.model.getElement());

this.element.setAttribute('aria-selected', 'true');
this.element.setAttribute('id', base64Id);
if (ariaLabel) {
this.element.setAttribute('aria-label', ariaLabel);
} else {
this.element.setAttribute('aria-labelledby', base64Id); // force screen reader to compute label from children (helps NVDA at least)
}
} else {
this.element.setAttribute('aria-selected', 'false');
this.element.removeAttribute('id');
this.element.removeAttribute('aria-label');
this.element.removeAttribute('aria-labelledby');
}
if (this.model.hasChildren()) {
this.element.setAttribute('aria-expanded', String(!!this.model.isExpanded()));
Expand Down

0 comments on commit 03284d8

Please sign in to comment.