mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-4879 Deatach tooltip card when directive is destroyed (#6939)
This commit is contained in:
committed by
GitHub
parent
aed2208205
commit
d37608111a
@@ -96,4 +96,17 @@ describe('TooltipCardDirective', () => {
|
|||||||
tooltipCard = overlay.querySelector<HTMLElement>('div.adf-tooltip-card');
|
tooltipCard = overlay.querySelector<HTMLElement>('div.adf-tooltip-card');
|
||||||
expect(tooltipCard).toBeNull();
|
expect(tooltipCard).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should hide tooltip-card on destroy', () => {
|
||||||
|
const span = fixture.debugElement.query(By.css('span.test-component'));
|
||||||
|
span.triggerEventHandler('mouseenter', {});
|
||||||
|
fixture.detectChanges();
|
||||||
|
let tooltipCard = overlay.querySelector<HTMLElement>('div.adf-tooltip-card');
|
||||||
|
expect(tooltipCard).not.toBeNull();
|
||||||
|
|
||||||
|
fixture.componentInstance.directive.ngOnDestroy();
|
||||||
|
fixture.detectChanges();
|
||||||
|
tooltipCard = overlay.querySelector<HTMLElement>('div.adf-tooltip-card');
|
||||||
|
expect(tooltipCard).toBeNull();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -14,13 +14,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* 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 { Overlay, OverlayPositionBuilder, OverlayRef } from '@angular/cdk/overlay';
|
||||||
import { ComponentPortal } from '@angular/cdk/portal';
|
import { ComponentPortal } from '@angular/cdk/portal';
|
||||||
import { TooltipCardComponent } from './tooltip-card.component';
|
import { TooltipCardComponent } from './tooltip-card.component';
|
||||||
|
|
||||||
@Directive({ selector: '[adf-tooltip-card]' })
|
@Directive({ selector: '[adf-tooltip-card]' })
|
||||||
export class TooltipCardDirective implements OnInit {
|
export class TooltipCardDirective implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@Input('adf-tooltip-card') text = '';
|
@Input('adf-tooltip-card') text = '';
|
||||||
@Input() image = '';
|
@Input() image = '';
|
||||||
@@ -41,6 +41,10 @@ export class TooltipCardDirective implements OnInit {
|
|||||||
private elementRef: ElementRef) {
|
private elementRef: ElementRef) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.hide();
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const positionStrategy = this.overlayPositionBuilder
|
const positionStrategy = this.overlayPositionBuilder
|
||||||
.flexibleConnectedTo(this.elementRef)
|
.flexibleConnectedTo(this.elementRef)
|
||||||
|
Reference in New Issue
Block a user