Skip to content

Commit

Permalink
refactor(material/timepicker): adds check for aria-labelledby for ove…
Browse files Browse the repository at this point in the history
…rride

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.
  • Loading branch information
essjay05 committed Jan 15, 2025
1 parent 6f60335 commit fc37006
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/material/timepicker/timepicker-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ export class MatTimepickerToggle<D> {
}

/**
* 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;
}
}
2 changes: 1 addition & 1 deletion tools/public_api_guard/material/timepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class MatTimepickerToggle<D> {
readonly ariaLabelledby: InputSignal<string | undefined>;
readonly disabled: InputSignalWithTransform<boolean, unknown>;
readonly disableRipple: InputSignalWithTransform<boolean, unknown>;
getAriaLabel(): string;
getAriaLabel(): string | null;
// (undocumented)
protected _isDisabled: Signal<boolean>;
protected _open(event: Event): void;
Expand Down

0 comments on commit fc37006

Please sign in to comment.