Skip to content

Allow undefined & null values in [matTooltip] explicitly #29397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/material/tooltip/tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,12 @@ describe('MDC-based MatTooltip', () => {
it('should not show tooltip if message is not present or empty', () => {
assertTooltipInstance(tooltipDirective, false);

tooltipDirective.message = undefined!;
tooltipDirective.message = undefined;
fixture.detectChanges();
tooltipDirective.show();
assertTooltipInstance(tooltipDirective, false);

tooltipDirective.message = null!;
tooltipDirective.message = null;
fixture.detectChanges();
tooltipDirective.show();
assertTooltipInstance(tooltipDirective, false);
Expand Down
4 changes: 2 additions & 2 deletions src/material/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ export class MatTooltip implements OnDestroy, AfterViewInit {

/** The message to be displayed in the tooltip */
@Input('matTooltip')
get message() {
get message(): string {
return this._message;
}

set message(value: string) {
set message(value: string | null | undefined) {
this._ariaDescriber.removeDescription(this._elementRef.nativeElement, this._message, 'tooltip');

// If the message is not a string (e.g. number), convert it to a string and trim it.
Expand Down
2 changes: 1 addition & 1 deletion tools/public_api_guard/material/tooltip.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
set hideDelay(value: NumberInput);
_isTooltipVisible(): boolean;
get message(): string;
set message(value: string);
set message(value: string | null | undefined);
// (undocumented)
ngAfterViewInit(): void;
ngOnDestroy(): void;
Expand Down
Loading