Skip to content

Commit 454ff0f

Browse files
authored
refactor(material/tooltip): drop NgClass dependency (#32666)
Remove the dependency on `NgClass` in the tooltip in favor of the `[class]` binding.
1 parent 71cdb84 commit 454ff0f

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

goldens/material/tooltip/index.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class TooltipComponent implements OnDestroy {
143143
protected _onShow(): void;
144144
show(delay: number): void;
145145
_tooltip: ElementRef<HTMLElement>;
146-
tooltipClass: string | string[] | Set<string> | {
146+
tooltipClass: string | string[] | {
147147
[key: string]: unknown;
148148
};
149149
_triggerElement: HTMLElement;

src/material/tooltip/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ ng_project(
7272
":css",
7373
],
7474
deps = [
75-
"//:node_modules/@angular/common",
7675
"//:node_modules/@angular/core",
7776
"//:node_modules/rxjs",
7877
"//src/cdk/coercion",

src/material/tooltip/tooltip.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div
22
#tooltip
33
class="mdc-tooltip mat-mdc-tooltip"
4-
[ngClass]="tooltipClass"
4+
[class]="tooltipClass"
55
(animationend)="_handleAnimationEnd($event)"
66
[class.mdc-tooltip--multiline]="_isMultiline">
77
<div class="mat-mdc-tooltip-surface mdc-tooltip__surface">{{message}}</div>

src/material/tooltip/tooltip.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
DOCUMENT,
3434
Renderer2,
3535
} from '@angular/core';
36-
import {NgClass} from '@angular/common';
3736
import {Platform} from '@angular/cdk/platform';
3837
import {AriaDescriber, FocusMonitor} from '@angular/cdk/a11y';
3938
import {Directionality} from '@angular/cdk/bidi';
@@ -719,7 +718,8 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
719718
tooltipClass: string | string[] | Set<string> | {[key: string]: unknown},
720719
) {
721720
if (this._tooltipInstance) {
722-
this._tooltipInstance.tooltipClass = tooltipClass;
721+
this._tooltipInstance.tooltipClass =
722+
tooltipClass instanceof Set ? Array.from(tooltipClass) : tooltipClass;
723723
this._tooltipInstance._markForCheck();
724724
}
725725
}
@@ -951,7 +951,6 @@ export class MatTooltip implements OnDestroy, AfterViewInit {
951951
'(mouseleave)': '_handleMouseLeave($event)',
952952
'aria-hidden': 'true',
953953
},
954-
imports: [NgClass],
955954
})
956955
export class TooltipComponent implements OnDestroy {
957956
private _changeDetectorRef = inject(ChangeDetectorRef);
@@ -963,8 +962,8 @@ export class TooltipComponent implements OnDestroy {
963962
/** Message to display in the tooltip */
964963
message!: string;
965964

966-
/** Classes to be added to the tooltip. Supports the same syntax as `ngClass`. */
967-
tooltipClass!: string | string[] | Set<string> | {[key: string]: unknown};
965+
/** Classes to be added to the tooltip. */
966+
tooltipClass!: string | string[] | {[key: string]: unknown};
968967

969968
/** The timeout ID of any current timer set to show the tooltip */
970969
private _showTimeoutId: ReturnType<typeof setTimeout> | undefined;

0 commit comments

Comments
 (0)