Skip to content

Commit

Permalink
fix(core/tooltip): cancel tooltip positioning when reference is not v…
Browse files Browse the repository at this point in the history
…isible (#1438)
  • Loading branch information
matthiashader authored Aug 29, 2024
1 parent 289cc33 commit 00c68b5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-ligers-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siemens/ix': patch
---

fix(core/tooltip): cancel tooltip positioning when reference is not visible
10 changes: 10 additions & 0 deletions packages/core/src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
computePosition,
ComputePositionReturn,
flip,
hide,
offset,
shift,
} from '@floating-ui/dom';
Expand Down Expand Up @@ -179,6 +180,7 @@ export class Tooltip implements IxOverlayComponent {
fallbackStrategy: 'initialPlacement',
padding: 10,
}),
hide(),
],
});
}
Expand All @@ -202,6 +204,14 @@ export class Tooltip implements IxOverlayComponent {
setTimeout(async () => {
const computeResponse = await this.computeTooltipPosition(target);

const isHidden =
computeResponse.middlewareData.hide?.referenceHidden;

if (isHidden) {
setTimeout(() => this.hideTooltip());
resolve(computeResponse);
}

if (computeResponse.middlewareData.arrow) {
this.applyTooltipArrowPosition(computeResponse);
}
Expand Down

0 comments on commit 00c68b5

Please sign in to comment.