Skip to content

Commit

Permalink
fix(module:tooltip): fix tooltip for deeply wrapped focusable elements (
Browse files Browse the repository at this point in the history
#6965)

* fix(module:tooltip): fix tooltip for work for wrapped focusable elements

close #6955

* test(module:tooltip): fix test
  • Loading branch information
wendell authored Sep 5, 2021
1 parent 013beda commit 78c16a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components/tooltip/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
4 changes: 2 additions & 2 deletions components/tooltip/tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
Expand Down

0 comments on commit 78c16a2

Please sign in to comment.