Skip to content

Commit 9678ca5

Browse files
committed
Fixes AB#488: ARIA label for select includes value
1 parent 4ed54c2 commit 9678ca5

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/@batch-flask/ui/select/select.component.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@ describe("SelectComponent", () => {
120120

121121
it("Should show placeholder when no value", () => {
122122
expect(labelEl.nativeElement.textContent).toContain("Myselect");
123+
expect(de.nativeElement.getAttribute("aria-label")).toContain("Myselect");
123124
});
124125

125126
it("Should show value when picked", () => {
126127
testComponent.value.setValue("opt-3");
127128
fixture.detectChanges();
128129
expect(labelEl.nativeElement.textContent).toContain("Carrot");
130+
expect(de.nativeElement.getAttribute("aria-label")).toEqual("Myselect: Carrot");
129131
});
130132

131133
it("list all options when clicking on button", async () => {

src/@batch-flask/ui/select/select.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class SelectComponent<TValue = any> implements FormFieldControl<any>, Opt
116116
@HostBinding("attr.aria-haspopup") public readonly ariaHasPopup = "listbox";
117117
@Input("attr.aria-label") @HostBinding("attr.aria-label")
118118
public set ariaLabel(label: string) { this._ariaLabel = label; }
119-
public get ariaLabel() { return this._ariaLabel || this.placeholder; }
119+
public get ariaLabel() { return this._ariaLabel || this.title; }
120120
@HostBinding("attr.aria-expanded") public get ariaExpanded() { return this.dropdownOpen; }
121121
@HostBinding("attr.aria-owns") public get ariaOwns() { return this.dropdownId; }
122122
@HostBinding("attr.tabindex") public readonly tabindex = -1;

0 commit comments

Comments
 (0)