Skip to content

Commit

Permalink
fix(tabs): fix aria-labelledby attribute (#1309)
Browse files Browse the repository at this point in the history
## PR Checklist

Please check if your PR fulfills the following requirements:

- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ] If applicable, have a visual design approval

## PR Type

What kind of change does this PR introduce?

<!-- Please check the one that applies to this PR using "x". -->

- [x] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:

## What is the current behavior?

<!-- Please describe the current behavior that you are modifying, or
link to a relevant issue. -->

Issue Number: CDE-1354

## What is the new behavior?

## Does this PR introduce a breaking change?

- [ ] Yes
- [x] No

<!-- If this PR contains a breaking change, please describe the impact
and migration path for existing applications below. -->

## Other information

This PR fixes getter method ariaLabelledBy to return correct tabLinkId.
Previously nothing was found in the getter function so the
aria-labelledby attrbute was not set. To be able to find the correct
tabLink I had to expose a getter of the id of the tabLink.

---------

Co-authored-by: Kevin Buhmann <[email protected]>
  • Loading branch information
mivaylo and kevinbuhmann authored Mar 11, 2024
1 parent faf161a commit 0fb6beb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions projects/angular/clarity.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3763,6 +3763,8 @@ export class ClrTabLink {
// (undocumented)
el: ElementRef;
// (undocumented)
readonly id: number;
// (undocumented)
ifActiveService: IfActiveService;
// (undocumented)
get inOverflow(): boolean;
Expand Down
2 changes: 1 addition & 1 deletion projects/angular/src/layout/tabs/tab-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class ClrTabContent implements OnDestroy {
}

get ariaLabelledBy(): string {
return this.tabsService.children.find(tab => tab.tabContent === this)?.tabLink?.tabLinkId;
return this.tabsService.children.find(tab => tab.tabLink.id === this.id)?.tabLink?.tabLinkId;
}

// The template must be applied on the top-down phase of view-child initialization to prevent
Expand Down
2 changes: 1 addition & 1 deletion projects/angular/src/layout/tabs/tab-link.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class ClrTabLink {

constructor(
public ifActiveService: IfActiveService,
@Inject(IF_ACTIVE_ID) private id: number,
@Inject(IF_ACTIVE_ID) readonly id: number,
public el: ElementRef,
private cfr: ComponentFactoryResolver,
private viewContainerRef: ViewContainerRef,
Expand Down

0 comments on commit 0fb6beb

Please sign in to comment.