-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[Tooltip] Tooltip does not vanish after route navigation with reusable routes #11478
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
Comments
we have the same issue. "dependencies": { |
Same issue, is it possible any workarounds for this issue? |
I also have same issue. Posted in StackOverflow and sample in stackblitz |
@Vizer Until this is fixed, I remove the tooltip manually with jquery from within the destination route component where the tooltip gets stuck: public ngAfterViewInit() { I know. Very ugly. |
@nharrer Thanks for the work around. I am not very sure it is right way do native. But it worked for me inside RouteReuseStrategy -> store method
Workaround StackBlitz |
@nharrer, thanks for message. I have came up with other solution using tooltip's methods. In my case it works like this:
Hope this helps someone :) |
Any update on this? |
There's the problem also in nebular 5.0. My current workaround: Not a real solution but i made my own tooltip using like this. >component.html
>component.scss
|
Another take on this one... On navigation start, detach the tooltip overlay. I tried to hide it via import {Directive, Injectable, OnDestroy, OnInit} from '@angular/core';
import {MatTooltip} from '@angular/material/tooltip';
import {NavigationStart, Router} from '@angular/router';
import {filter} from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class TooltipCollector {
collection = new Set<MatTooltip>();
constructor(router: Router) {
router.events.pipe(filter(e => e instanceof NavigationStart)).subscribe(() => {
for (let mt of this.collection) {
if (mt._tooltipInstance?.isVisible()) {
mt._overlayRef?.detach();
break;
}
}
});
}
}
@Directive({
selector: '[matTooltip]',
})
export class HideTooltipDirective implements OnInit, OnDestroy {
constructor(private mt: MatTooltip, private tc: TooltipCollector) {}
ngOnInit() {
this.tc.collection.add(this.mt);
}
ngOnDestroy() {
this.tc.collection.delete(this.mt);
}
} |
Here is how I had to handle it for any overlays:
or in the AppComponent
|
@setbro-prg Your solution doesn't work for me, cdk-overlay-backdrop-showing does not exists (Angular 13.2.5). I found a solution using Router events to empty the overlay container on each NavigationStart event:
|
I ran across this issue while debugging something similar related to matMenuTrigger, but my issue was calling an async function outside of the Angular zone. What fixed it for me was running closeMenu() within NgZone.
Without this, Angular was unaware that any changes had occured and wasn't removing the CDK overlay. |
Uh oh!
There was an error while loading. Please reload this page.
Bug, feature request, or proposal:
Bug
What is the expected behavior?
A displayed tooltip should vanish, after navigating to a route with a different component.
What is the current behavior?
When a RouteReuseStrategy is implemented, then the tooltip doesn't vanish if the original route is detached while the tooltip was visible.
What are the steps to reproduce?
StackBlitz example: https://stackblitz.com/edit/angular-yvcjzp
A tooltip is displayed on button "Goto Page 2". Clicking on the button will navigate to page 2. This will causes the tooltip from page 1 to be stuck on the screen. It will only vanish once the user navigates back to page 1 again.
Disabling reusable routes by removing the custom RouteReuseStrategy will lead to the the expected behavior again:
What is the use-case or motivation for changing an existing behavior?
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
"dependencies": {
"@angular/animations": "6.0.0",
"@angular/cdk": "^6.0.0",
"@angular/common": "6.0.0",
"@angular/compiler": "6.0.0",
"@angular/core": "6.0.0",
"@angular/forms": "6.0.0",
"@angular/http": "6.0.0",
"@angular/material": "^6.0.0",
"@angular/platform-browser": "6.0.0",
"@angular/platform-browser-dynamic": "6.0.0",
"@angular/router": "6.0.0",
"core-js": "^2.4.1",
"rxjs": "^6.1.0",
"rxjs-compat": "^6.1.0",
"zone.js": "^0.8.26"
},
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: