Skip to content

Commit b48367a

Browse files
authored
SelectBox: Add setAriaLabel() Fixes: microsoft#54412 (microsoft#54446)
1 parent ed25759 commit b48367a

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/vs/base/browser/ui/selectBox/selectBox.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface ISelectBoxDelegate {
2323
readonly onDidSelect: Event<ISelectData>;
2424
setOptions(options: string[], selected?: number, disabled?: number): void;
2525
select(index: number): void;
26+
setAriaLabel(label: string);
2627
focus(): void;
2728
blur(): void;
2829
dispose(): void;
@@ -90,6 +91,10 @@ export class SelectBox extends Widget implements ISelectBoxDelegate {
9091
this.selectBoxDelegate.select(index);
9192
}
9293

94+
public setAriaLabel(label: string): void {
95+
this.selectBoxDelegate.setAriaLabel(label);
96+
}
97+
9398
public focus(): void {
9499
this.selectBoxDelegate.focus();
95100
}

src/vs/base/browser/ui/selectBox/selectBoxCustom.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ export class SelectBoxList implements ISelectBoxDelegate, IVirtualDelegate<ISele
276276
this.selectElement.title = this.options[this.selected];
277277
}
278278

279+
public setAriaLabel(label: string): void {
280+
this.selectBoxOptions.ariaLabel = label;
281+
this.selectElement.setAttribute('aria-label', this.selectBoxOptions.ariaLabel);
282+
this.selectList.getHTMLElement().setAttribute('aria-label', this.selectBoxOptions.ariaLabel);
283+
}
284+
279285
public focus(): void {
280286
if (this.selectElement) {
281287
this.selectElement.focus();

src/vs/base/browser/ui/selectBox/selectBoxNative.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ export class SelectBoxNative implements ISelectBoxDelegate {
108108
this.selectElement.title = this.options[this.selected];
109109
}
110110

111+
public setAriaLabel(label: string): void {
112+
this.selectBoxOptions.ariaLabel = label;
113+
this.selectElement.setAttribute('aria-label', label);
114+
}
115+
111116
public focus(): void {
112117
if (this.selectElement) {
113118
this.selectElement.focus();

0 commit comments

Comments
 (0)