Skip to content

Commit

Permalink
Merge pull request #16322 from primefaces/issue-16321
Browse files Browse the repository at this point in the history
Fixed #16321 - Tooltip | tooltip on Dropdown causes Errors
  • Loading branch information
mehmetcetin01140 authored Sep 10, 2024
2 parents c859aed + 84159fb commit c8ceffa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/app/components/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ export class Tooltip implements AfterViewInit, OnDestroy {
this.focusListener = this.onFocus.bind(this);
this.blurListener = this.onBlur.bind(this);

let target = this.getTarget(this.el.nativeElement);
let target = this.el.nativeElement.querySelector('.p-component');

if (!target) {
target = this.getTarget(this.el.nativeElement);
}

target.addEventListener('focus', this.focusListener);
target.addEventListener('blur', this.blurListener);
Expand Down Expand Up @@ -601,7 +605,7 @@ export class Tooltip implements AfterViewInit, OnDestroy {
}

getTarget(el: Element) {
return DomHandler.hasClass(el, 'p-inputwrapper') ? DomHandler.findSingle(el, 'input') : el.querySelector('.p-component') || el;
return DomHandler.hasClass(el, 'p-inputwrapper') ? DomHandler.findSingle(el, 'input') : el;
}

preAlign(position: string) {
Expand Down Expand Up @@ -668,10 +672,11 @@ export class Tooltip implements AfterViewInit, OnDestroy {
this.el.nativeElement.removeEventListener('click', this.clickListener);
}
if (tooltipEvent === 'focus' || tooltipEvent === 'both') {
let target = this.getTarget(this.el.nativeElement);
let target = this.el.nativeElement.querySelector('.p-component');

target.removeEventListener('focus', this.focusListener);
target.removeEventListener('blur', this.blurListener);
if (!target) {
target = this.getTarget(this.el.nativeElement);
}
}
this.unbindDocumentResizeListener();
}
Expand Down

0 comments on commit c8ceffa

Please sign in to comment.