AAE-4879 Deatach tooltip card when directive is destroyed (#6939)

This commit is contained in:
Pablo Martinez Garcia
2021-04-20 10:21:22 +02:00
committed by GitHub
parent aed2208205
commit d37608111a
2 changed files with 19 additions and 2 deletions

View File

@@ -14,13 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ComponentRef, Directive, ElementRef, HostListener, Input, OnInit } from '@angular/core';
import { ComponentRef, Directive, ElementRef, HostListener, Input, OnDestroy, OnInit } from '@angular/core';
import { Overlay, OverlayPositionBuilder, OverlayRef } from '@angular/cdk/overlay';
import { ComponentPortal } from '@angular/cdk/portal';
import { TooltipCardComponent } from './tooltip-card.component';
@Directive({ selector: '[adf-tooltip-card]' })
export class TooltipCardDirective implements OnInit {
export class TooltipCardDirective implements OnInit, OnDestroy {
@Input('adf-tooltip-card') text = '';
@Input() image = '';
@@ -41,6 +41,10 @@ export class TooltipCardDirective implements OnInit {
private elementRef: ElementRef) {
}
ngOnDestroy(): void {
this.hide();
}
ngOnInit(): void {
const positionStrategy = this.overlayPositionBuilder
.flexibleConnectedTo(this.elementRef)