Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(a11y): treeview incorrect levels (backport to 16.x) #1385

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion projects/angular/src/data/tree-view/recursive-children.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { TreeFeaturesService } from './tree-features.service';
</ng-container>
`,
host: {
'[attr.role]': '"group"', // Safari + VO needs direct relationship between treeitem and group; no element should exist between them
'[attr.role]': 'role', // Safari + VO needs direct relationship between treeitem and group; no element should exist between them
},
})
/**
Expand All @@ -37,6 +37,7 @@ export class RecursiveChildren<T> {
@Input('children') children: TreeNodeModel<T>[];

subscription: Subscription;
role: string;

constructor(public featuresService: TreeFeaturesService<T>, @Optional() private expandService: IfExpandService) {
if (expandService) {
Expand All @@ -51,6 +52,10 @@ export class RecursiveChildren<T> {
}
}

ngAfterContentInit() {
this.setAriaRoles();
}

shouldRender() {
return (
this.featuresService.recursion &&
Expand All @@ -73,4 +78,8 @@ export class RecursiveChildren<T> {
this.subscription.unsubscribe();
}
}

private setAriaRoles() {
this.role = this.parent ? 'group' : null;
}
}
Loading