Skip to content

Commit

Permalink
fix: Ensure screenreaders read combobox label (#2919)
Browse files Browse the repository at this point in the history
Signed-off-by: Akshat Patel <[email protected]>
  • Loading branch information
Akshat55 authored Jun 13, 2024
1 parent e167388 commit 9135eeb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/combobox/combobox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { Observable } from "rxjs";
<label
*ngIf="label"
[for]="id"
[id]="labelId"
class="cds--label"
[ngClass]="{'cds--label--disabled': disabled}">
<ng-container *ngIf="!isTemplate(label)">{{label}}</ng-container>
Expand Down Expand Up @@ -110,7 +111,7 @@ import { Observable } from "rxjs";
[ngClass]="{'cds--text-input--empty': !showClearButton}"
tabindex="0"
[id]="id"
[attr.aria-labelledby]="id"
[attr.aria-labelledby]="labelId"
[attr.aria-expanded]="open"
aria-haspopup="listbox"
[attr.maxlength]="maxLength"
Expand Down Expand Up @@ -258,6 +259,7 @@ export class ComboBox implements OnChanges, AfterViewInit, AfterContentInit, OnD
}
static comboBoxCount = 0;
@Input() id = `dropdown-${ComboBox.comboBoxCount++}`;
@Input() labelId = `dropdown-label-${ComboBox.comboBoxCount++}`;
/**
* List of items to fill the content with.
*
Expand Down

0 comments on commit 9135eeb

Please sign in to comment.