@@ -860,7 +860,7 @@ export abstract class _TooltipComponentBase implements OnDestroy {
860
860
_mouseLeaveHideDelay : number ;
861
861
862
862
/** Whether animations are currently disabled. */
863
- _animationsDisabled : boolean ;
863
+ private _animationsDisabled : boolean ;
864
864
865
865
/** Reference to the internal tooltip element. */
866
866
abstract _tooltip : ElementRef < HTMLElement > ;
@@ -895,15 +895,9 @@ export abstract class _TooltipComponentBase implements OnDestroy {
895
895
// Cancel the delayed hide if it is scheduled
896
896
clearTimeout ( this . _hideTimeoutId ) ;
897
897
898
- // Body interactions should cancel the tooltip if there is a delay in showing.
899
- this . _closeOnInteraction = true ;
900
898
this . _showTimeoutId = setTimeout ( ( ) => {
901
- this . _toogleVisibility ( true ) ;
899
+ this . _toggleVisibility ( true ) ;
902
900
this . _showTimeoutId = undefined ;
903
-
904
- // Mark for check so if any parent component has set the
905
- // ChangeDetectionStrategy to OnPush it will be checked anyways
906
- this . _markForCheck ( ) ;
907
901
} , delay ) ;
908
902
}
909
903
@@ -916,12 +910,8 @@ export abstract class _TooltipComponentBase implements OnDestroy {
916
910
clearTimeout ( this . _showTimeoutId ) ;
917
911
918
912
this . _hideTimeoutId = setTimeout ( ( ) => {
919
- this . _toogleVisibility ( false ) ;
913
+ this . _toggleVisibility ( false ) ;
920
914
this . _hideTimeoutId = undefined ;
921
-
922
- // Mark for check so if any parent component has set the
923
- // ChangeDetectionStrategy to OnPush it will be checked anyways
924
- this . _markForCheck ( ) ;
925
915
} , delay ) ;
926
916
}
927
917
@@ -984,30 +974,45 @@ export abstract class _TooltipComponentBase implements OnDestroy {
984
974
985
975
/** Handles the cleanup after an animation has finished. */
986
976
private _finalizeAnimation ( toVisible : boolean ) {
987
- if ( ! toVisible && ! this . isVisible ( ) ) {
977
+ if ( toVisible ) {
978
+ this . _closeOnInteraction = true ;
979
+ } else if ( ! this . isVisible ( ) ) {
988
980
this . _onHide . next ( ) ;
989
981
}
990
-
991
- this . _closeOnInteraction = true ;
992
982
}
993
983
994
984
/** Toggles the visibility of the tooltip element. */
995
- private _toogleVisibility ( isVisible : boolean ) {
985
+ private _toggleVisibility ( isVisible : boolean ) {
996
986
// We set the classes directly here ourselves so that toggling the tooltip state
997
987
// isn't bound by change detection. This allows us to hide it even if the
998
988
// view ref has been detached from the CD tree.
999
- const classList = this . _tooltip . nativeElement . classList ;
989
+ const tooltip = this . _tooltip . nativeElement ;
1000
990
const showClass = this . _showAnimation ;
1001
991
const hideClass = this . _hideAnimation ;
1002
- classList . remove ( isVisible ? hideClass : showClass ) ;
1003
- classList . add ( isVisible ? showClass : hideClass ) ;
992
+ tooltip . classList . remove ( isVisible ? hideClass : showClass ) ;
993
+ tooltip . classList . add ( isVisible ? showClass : hideClass ) ;
1004
994
this . _isVisible = isVisible ;
1005
995
996
+ // It's common for internal apps to disable animations using `* { animation: none !important }`
997
+ // which can break the opening sequence. Try to detect such cases and work around them.
998
+ if ( isVisible && ! this . _animationsDisabled && typeof getComputedStyle === 'function' ) {
999
+ const styles = getComputedStyle ( tooltip ) ;
1000
+
1001
+ // Use `getPropertyValue` to avoid issues with property renaming.
1002
+ if (
1003
+ styles . getPropertyValue ( 'animation-duration' ) === '0s' ||
1004
+ styles . getPropertyValue ( 'animation-name' ) === 'none'
1005
+ ) {
1006
+ this . _animationsDisabled = true ;
1007
+ }
1008
+ }
1009
+
1006
1010
if ( isVisible ) {
1007
1011
this . _onShow ( ) ;
1008
1012
}
1009
1013
1010
1014
if ( this . _animationsDisabled ) {
1015
+ tooltip . classList . add ( '_mat-animation-noopable' ) ;
1011
1016
this . _finalizeAnimation ( isVisible ) ;
1012
1017
}
1013
1018
}
0 commit comments