diff --git a/.changeset/popular-crabs-reply.md b/.changeset/popular-crabs-reply.md new file mode 100644 index 0000000000..d407002c1b --- /dev/null +++ b/.changeset/popular-crabs-reply.md @@ -0,0 +1,5 @@ +--- +"@siemens/ix": patch +--- + +fix(core/tooltip): null check before event listener gets registered on trigger diff --git a/packages/core/src/components/tooltip/tooltip.tsx b/packages/core/src/components/tooltip/tooltip.tsx index e6c41835c0..ce93a023cf 100644 --- a/packages/core/src/components/tooltip/tooltip.tsx +++ b/packages/core/src/components/tooltip/tooltip.tsx @@ -231,7 +231,7 @@ export class Tooltip implements IxOverlayComponent { } } - private async queryAnchorElements(): Promise> { + private async queryAnchorElements(): Promise | undefined> { if (typeof this.for === 'string') { return Promise.resolve(Array.from(document.querySelectorAll(this.for))); } @@ -253,6 +253,10 @@ export class Tooltip implements IxOverlayComponent { this.disposeListener(); } + if (!triggerElementList) { + return; + } + triggerElementList.forEach((element) => { const onMouseEnter = () => { this.showTooltip(element);