提交 258c55e7 编写于 作者: J Joao Moreno

list aria-level, tree uses depth

related to #66584
上级 24b9056e
......@@ -627,9 +627,14 @@ export interface IAccessibilityProvider<T> {
* Returning null will not disable ARIA for the element. Instead it is up to the screen reader
* to compute a meaningful label based on the contents of the element in the DOM
*
* See also: https://www.w3.org/TR/wai-aria/states_and_properties#aria-label
* See also: https://www.w3.org/TR/wai-aria/#aria-label
*/
getAriaLabel(element: T): string | null;
/**
* https://www.w3.org/TR/wai-aria/#aria-level
*/
getAriaLevel?(element: T): number | undefined;
}
export class DefaultStyleController implements IStyleController {
......@@ -918,9 +923,7 @@ class AccessibiltyRenderer<T> implements IListRenderer<T, HTMLElement> {
templateId: string = 'a18n';
constructor(private accessibilityProvider: IAccessibilityProvider<T>) {
}
constructor(private accessibilityProvider: IAccessibilityProvider<T>) { }
renderTemplate(container: HTMLElement): HTMLElement {
return container;
......@@ -934,6 +937,14 @@ class AccessibiltyRenderer<T> implements IListRenderer<T, HTMLElement> {
} else {
container.removeAttribute('aria-label');
}
const ariaLevel = this.accessibilityProvider.getAriaLevel && this.accessibilityProvider.getAriaLevel(element);
if (typeof ariaLevel === 'number') {
container.setAttribute('aria-level', `${ariaLevel}`);
} else {
container.removeAttribute('aria-level');
}
}
disposeTemplate(templateData: any): void {
......
......@@ -131,6 +131,9 @@ function asListOptions<T, TFilterData, TRef>(modelProvider: () => ITreeModel<T,
accessibilityProvider: options.accessibilityProvider && {
getAriaLabel(e) {
return options.accessibilityProvider!.getAriaLabel(e.element);
},
getAriaLevel(node) {
return node.depth;
}
},
keyboardNavigationLabelProvider: options.keyboardNavigationLabelProvider && {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册