From 9ae775f19d4969e78632855848efd45ce0aad90b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20=C3=87etin?= <92744169+mehmetcetin01140@users.noreply.github.com> Date: Fri, 26 Jul 2024 11:39:45 +0300 Subject: [PATCH] Fixed #16106 - Password | Tooltip with tooltipEvent='focus' is never displayed --- src/app/components/tooltip/tooltip.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/app/components/tooltip/tooltip.ts b/src/app/components/tooltip/tooltip.ts index 5fe32510ef5..038d05533d1 100755 --- a/src/app/components/tooltip/tooltip.ts +++ b/src/app/components/tooltip/tooltip.ts @@ -185,11 +185,7 @@ export class Tooltip implements AfterViewInit, OnDestroy { this.focusListener = this.onFocus.bind(this); this.blurListener = this.onBlur.bind(this); - let target = this.el.nativeElement.querySelector('.p-component'); - - if (!target) { - target = this.getTarget(this.el.nativeElement); - } + let target = this.getTarget(this.el.nativeElement); target.addEventListener('focus', this.focusListener); target.addEventListener('blur', this.blurListener); @@ -605,7 +601,7 @@ export class Tooltip implements AfterViewInit, OnDestroy { } getTarget(el: Element) { - return DomHandler.hasClass(el, 'p-inputwrapper') ? DomHandler.findSingle(el, 'input') : el; + return DomHandler.hasClass(el, 'p-inputwrapper') ? DomHandler.findSingle(el, 'input') : el.querySelector('.p-component') || el; } preAlign(position: string) { @@ -672,11 +668,9 @@ export class Tooltip implements AfterViewInit, OnDestroy { this.el.nativeElement.removeEventListener('click', this.clickListener); } if (tooltipEvent === 'focus' || tooltipEvent === 'both') { - let target = this.el.nativeElement.querySelector('.p-component'); - - if (!target) { - target = this.getTarget(this.el.nativeElement); - } + + let target = this.getTarget(this.el.nativeElement); + target.removeEventListener('focus', this.focusListener); target.removeEventListener('blur', this.blurListener); @@ -740,3 +734,4 @@ export class Tooltip implements AfterViewInit, OnDestroy { declarations: [Tooltip] }) export class TooltipModule {} +