Skip to content

Commit

Permalink
fix(material/tooltip): avoid problem when triggers hide animation for…
Browse files Browse the repository at this point in the history
… not visible tooltip (#24652)

Fixes a bug in Angular Material `tooltip` when `mat-tooltip-hide` class trigger animation for not visible tooltip.

Fixes #24614

(cherry picked from commit 3041cda)
  • Loading branch information
volvachev authored and wagnermaciel committed Aug 4, 2022
1 parent 1381cc0 commit 0f2ec70
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/material/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,8 +989,22 @@ export abstract class _TooltipComponentBase implements OnDestroy {
const tooltip = this._tooltip.nativeElement;
const showClass = this._showAnimation;
const hideClass = this._hideAnimation;
tooltip.classList.remove(isVisible ? hideClass : showClass);
tooltip.classList.add(isVisible ? showClass : hideClass);

if (isVisible) {
tooltip.classList.remove(hideClass);
tooltip.classList.add(showClass);
}

if (!isVisible) {
// It's avoids the problem when `mat-tooltip-hide` triggers the animation of
// a tooltip that has not been shown yet.
if (tooltip.classList.contains(showClass)) {
tooltip.classList.add(hideClass);
}

tooltip.classList.remove(showClass);
}

this._isVisible = isVisible;

// It's common for internal apps to disable animations using `* { animation: none !important }`
Expand Down

0 comments on commit 0f2ec70

Please sign in to comment.