From 88e48128713f5fc47d9f65b3164c69cfe5bcf849 Mon Sep 17 00:00:00 2001 From: wendellhu95 Date: Thu, 2 Sep 2021 17:09:27 +0800 Subject: [PATCH 1/2] fix(module:tooltip): fix tooltip for work for wrapped focusable elements close #6955 --- components/tooltip/base.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/tooltip/base.ts b/components/tooltip/base.ts index 905efd4d482..da5074c57c1 100644 --- a/components/tooltip/base.ts +++ b/components/tooltip/base.ts @@ -231,8 +231,8 @@ export abstract class NzTooltipBaseDirective implements OnChanges, OnDestroy, Af }) ); } else if (trigger === 'focus') { - this.triggerDisposables.push(this.renderer.listen(el, 'focus', () => this.show())); - this.triggerDisposables.push(this.renderer.listen(el, 'blur', () => this.hide())); + this.triggerDisposables.push(this.renderer.listen(el, 'focusin', () => this.show())); + this.triggerDisposables.push(this.renderer.listen(el, 'focusout', () => this.hide())); } else if (trigger === 'click') { this.triggerDisposables.push( this.renderer.listen(el, 'click', (e: MouseEvent) => { From 7c5f24914922ccbc9f9b2a3aeef2fc4563f9e0bb Mon Sep 17 00:00:00 2001 From: wendellhu95 Date: Thu, 2 Sep 2021 17:29:40 +0800 Subject: [PATCH 2/2] test(module:tooltip): fix test --- components/tooltip/tooltip.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/tooltip/tooltip.spec.ts b/components/tooltip/tooltip.spec.ts index 006c5d0f20b..fd30b11643e 100644 --- a/components/tooltip/tooltip.spec.ts +++ b/components/tooltip/tooltip.spec.ts @@ -134,11 +134,11 @@ describe('nz-tooltip', () => { const title = 'focus'; const triggerElement = component.focusTemplate.nativeElement; - dispatchMouseEvent(triggerElement, 'focus'); + dispatchMouseEvent(triggerElement, 'focusin'); waitingForTooltipToggling(); expect(overlayContainerElement.textContent).toContain(title); - dispatchMouseEvent(triggerElement, 'blur'); + dispatchMouseEvent(triggerElement, 'focusout'); waitingForTooltipToggling(); expect(overlayContainerElement.textContent).not.toContain(title); }));