提交 5ec01d95 编写于 作者: B Benjamin Pasero

a18y: avoid duplicate events when navigating trees (for #26730)

上级 1d0b00c6
...@@ -197,22 +197,18 @@ export class ViewItem implements IViewItem { ...@@ -197,22 +197,18 @@ export class ViewItem implements IViewItem {
// ARIA // ARIA
this.element.setAttribute('role', 'treeitem'); 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')) { if (this.model.hasTrait('focused')) {
const base64Id = strings.safeBtoa(this.model.id); 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('aria-selected', 'true');
this.element.setAttribute('id', base64Id); 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 { } else {
this.element.setAttribute('aria-selected', 'false'); this.element.setAttribute('aria-selected', 'false');
this.element.removeAttribute('id'); this.element.removeAttribute('id');
this.element.removeAttribute('aria-label');
this.element.removeAttribute('aria-labelledby');
} }
if (this.model.hasChildren()) { if (this.model.hasChildren()) {
this.element.setAttribute('aria-expanded', String(!!this.model.isExpanded())); this.element.setAttribute('aria-expanded', String(!!this.model.isExpanded()));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册