-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(tooltip): not working properly with ChangeDetectionStrategy.OnPush #2721
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ import { | |
AnimationTransitionEvent, | ||
NgZone, | ||
Optional, | ||
OnDestroy | ||
OnDestroy, | ||
ChangeDetectorRef | ||
} from '@angular/core'; | ||
import { | ||
Overlay, | ||
|
@@ -286,7 +287,7 @@ export class TooltipComponent { | |
/** Subject for notifying that the tooltip has been hidden from the view */ | ||
private _onHide: Subject<any> = new Subject(); | ||
|
||
constructor(@Optional() private _dir: Dir) {} | ||
constructor(@Optional() private _dir: Dir, private _ref: ChangeDetectorRef) {} | ||
|
||
/** | ||
* Shows the tooltip with an animation originating from the provided origin | ||
|
@@ -309,6 +310,10 @@ export class TooltipComponent { | |
// If this was set to true immediately, then a body click that triggers show() would | ||
// trigger interaction and close the tooltip right after it was displayed. | ||
this._closeOnInteraction = false; | ||
|
||
// Call change detection manually so tooltip will also work | ||
// if any parent component has set the ChangeDetectionStrategy to OnPush | ||
this._ref.detectChanges(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think rather than always triggering a We are doing this in other components as well.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jelbourn is there a way to find out if a parent component has set the |
||
setTimeout(() => { this._closeOnInteraction = true; }, 0); | ||
}, delay); | ||
} | ||
|
@@ -326,6 +331,10 @@ export class TooltipComponent { | |
this._hideTimeoutId = setTimeout(() => { | ||
this._visibility = 'hidden'; | ||
this._closeOnInteraction = false; | ||
|
||
// Call change detection manually so tooltip will also work | ||
// if any parent component has set the ChangeDetectionStrategy to OnPush | ||
this._ref.detectChanges(); | ||
}, delay); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ref
is not very precise. It should be_changeDetectorRef