From 2ceb536eca0e6f14efa8731545896fa88aab16bf Mon Sep 17 00:00:00 2001 From: Joy Serquina Date: Fri, 10 Jan 2025 18:13:05 +0000 Subject: [PATCH] refactor(material/timepicker): adds check for aria-labelledby for override Updates previous fix which implements a default aria-label if no custom aria-label is provided to where it checks if an aria-lablledby value is provided and uses the aria-labelledby value if available. If not it will check for a custom aria-label and if that is not provided it will default to the generic aria-label value. --- src/material/timepicker/timepicker-toggle.ts | 9 ++++----- tools/public_api_guard/material/timepicker.md | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/material/timepicker/timepicker-toggle.ts b/src/material/timepicker/timepicker-toggle.ts index 193959bb841c..1bf7a67fcdad 100644 --- a/src/material/timepicker/timepicker-toggle.ts +++ b/src/material/timepicker/timepicker-toggle.ts @@ -94,11 +94,10 @@ export class MatTimepickerToggle { } /** - * Gets the aria-label to use for the toggle button. - * Returns the user-provided aria-label if one exists, - * otherwise returns the default aria-label using the timepicker's panelId. + * Checks for ariaLabelledby and if empty uses custom + * aria-label or defaultAriaLabel if neither is provided. */ - getAriaLabel(): string { - return this.ariaLabel() || this._defaultAriaLabel; + getAriaLabel(): string | null { + return this.ariaLabelledby() ? null : this.ariaLabel() || this._defaultAriaLabel; } } diff --git a/tools/public_api_guard/material/timepicker.md b/tools/public_api_guard/material/timepicker.md index 472a71f3901d..d99141df8ddc 100644 --- a/tools/public_api_guard/material/timepicker.md +++ b/tools/public_api_guard/material/timepicker.md @@ -127,7 +127,7 @@ export class MatTimepickerToggle { readonly ariaLabelledby: InputSignal; readonly disabled: InputSignalWithTransform; readonly disableRipple: InputSignalWithTransform; - getAriaLabel(): string; + getAriaLabel(): string | null; // (undocumented) protected _isDisabled: Signal; protected _open(event: Event): void;