Skip to content

Commit 7ae1102

Browse files
ktranDevtools-frontend LUCI CQ
authored andcommitted
Update CheckboxLabel to set aria-label on the input element
For a11y, we need to set aria-label on input elements. When re-enabling a the web test, it complained about missing aria-labels in the DOM breakpoints sidebar pane. This CL updates CheckboxLabel to observe aria-label attribute changes and set them on the inner input element. See https://crrev.com/c/6591321 for the re-enabled web test update. Bug: 325443331 Change-Id: I5e141b1f08aed9480aed870fe4d63301d8fba53c Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6595128 Reviewed-by: Danil Somsikov <dsv@chromium.org> Auto-Submit: Kim-Anh Tran <kimanh@chromium.org> Commit-Queue: Kim-Anh Tran <kimanh@chromium.org> Commit-Queue: Danil Somsikov <dsv@chromium.org>
1 parent 841573b commit 7ae1102

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

front_end/ui/legacy/UIUtils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ export function setTitle(element: HTMLElement, title: string): void {
13051305
}
13061306

13071307
export class CheckboxLabel extends HTMLElement {
1308-
static readonly observedAttributes = ['checked', 'disabled', 'indeterminate', 'name', 'title'];
1308+
static readonly observedAttributes = ['checked', 'disabled', 'indeterminate', 'name', 'title', 'aria-label'];
13091309

13101310
readonly #shadowRoot!: DocumentFragment;
13111311
#checkboxElement!: HTMLInputElement;
@@ -1362,9 +1362,19 @@ export class CheckboxLabel extends HTMLElement {
13621362
} else if (name === 'title') {
13631363
this.#checkboxElement.title = newValue ?? '';
13641364
this.#textElement.title = newValue ?? '';
1365+
} else if (name === 'aria-label') {
1366+
this.#checkboxElement.ariaLabel = newValue;
13651367
}
13661368
}
13671369

1370+
override get ariaLabel(): string|null {
1371+
return this.#checkboxElement.ariaLabel;
1372+
}
1373+
1374+
override set ariaLabel(ariaLabel: string) {
1375+
this.setAttribute('aria-label', ariaLabel);
1376+
}
1377+
13681378
get checked(): boolean {
13691379
return this.#checkboxElement.checked;
13701380
}

0 commit comments

Comments
 (0)