Skip to content

Commit

Permalink
Fixed #14264 - Tooltip | Cannot read properties of null (reading 'add…
Browse files Browse the repository at this point in the history
…EventListener') if tooltipEvent is of type focus
  • Loading branch information
mehmetcetin01140 committed Dec 27, 2023
1 parent a99d8d6 commit f3bdfe0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/app/components/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ 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);
const targetElement = this.el.nativeElement;
const defaultTarget = DomHandler.getFocusableElements(targetElement)[0];
const target = this.getTarget(targetElement) || this.getTarget(defaultTarget);
target.addEventListener('focus', this.focusListener);
target.addEventListener('blur', this.blurListener);
}
Expand Down Expand Up @@ -637,9 +639,13 @@ export class Tooltip implements AfterViewInit, OnDestroy {
this.el.nativeElement.removeEventListener('mouseenter', this.mouseEnterListener);
this.el.nativeElement.removeEventListener('mouseleave', this.mouseLeaveListener);
this.el.nativeElement.removeEventListener('click', this.clickListener);
} else if (this.getOption('tooltipEvent') === 'focus') {
let target = this.getTarget(this.el.nativeElement);

}

else if (this.getOption('tooltipEvent') === 'focus') {
const targetElement = this.el.nativeElement;
const defaultTarget = DomHandler.getFocusableElements(targetElement)[0];
const target = this.getTarget(targetElement) || this.getTarget(defaultTarget);

target.removeEventListener('focus', this.focusListener);
target.removeEventListener('blur', this.blurListener);
}
Expand Down Expand Up @@ -703,3 +709,4 @@ export class Tooltip implements AfterViewInit, OnDestroy {
declarations: [Tooltip]
})
export class TooltipModule {}

0 comments on commit f3bdfe0

Please sign in to comment.