Skip to content

Commit

Permalink
fix(tree-view): ensure node text and screen reader text are separate
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbuhmann committed Nov 9, 2022
1 parent e2d6d02 commit 21988ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions projects/angular/src/data/tree-view/tree-node.html
Expand Up @@ -49,8 +49,8 @@
<div class="clr-treenode-content" (mousedown)="focusTreeNode()">
<ng-content></ng-content>
<div class="clr-sr-only" *ngIf="featuresService.selectable">
<span *ngIf="ariaSelected">selected</span>
<span *ngIf="!ariaSelected">unselected</span>
<span *ngIf="ariaSelected"> selected</span>
<span *ngIf="!ariaSelected"> unselected</span>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions projects/angular/src/data/tree-view/tree-node.spec.ts
Expand Up @@ -344,14 +344,14 @@ export default function (): void {
this.clarityDirective.selected = ClrSelectedState.SELECTED;
this.detectChanges();
expect(contentContainer.getAttribute('aria-selected')).toBe('true');
expect(contentContainer.textContent.trim()).toBe('Hello world selected');
expect(contentContainer.textContent.trim().replace(/\s+/g, ' ')).toBe('Hello world selected');
});

it('adds the aria-selected attribute and screen reader text to unselected tree nodes', function (this: Context) {
this.clarityDirective.selected = ClrSelectedState.UNSELECTED;
this.detectChanges();
expect(contentContainer.getAttribute('aria-selected')).toBe('false');
expect(contentContainer.textContent.trim()).toBe('Hello world unselected');
expect(contentContainer.textContent.trim().replace(/\s+/g, ' ')).toBe('Hello world unselected');
});

it('does not add the aria-selected attribute or screen reader text to non-selectable tree nodes', function (this: Context) {
Expand Down

0 comments on commit 21988ab

Please sign in to comment.