Skip to content

Commit

Permalink
refactor(tooltip): simplify tooltip rendering logic by removing condi…
Browse files Browse the repository at this point in the history
…tional rendering for visibility
  • Loading branch information
developerjhp committed Dec 2, 2024
1 parent cd5d66e commit ccca3cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
3 changes: 0 additions & 3 deletions packages/tooltip/src/Tooltip.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
transform: scale(0.95);
transition: opacity 0.3s ease, transform 0.3s ease;
pointer-events: none;

top: -9999px;
left: -9999px;
}

.tooltip.visible {
Expand Down
28 changes: 12 additions & 16 deletions packages/tooltip/src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,18 @@ export const Tooltip = forwardRef(function Tooltip(
>
{children}
</Component>
{isVisible &&
createPortal(
<div
ref={tooltipRef}
className={clsx(
styles.tooltip,
styles[placement],
tooltipClassName,
{ [styles.visible]: isVisible },
)}
style={{ ...tooltipStyles, ...tooltipStyle }}
>
{tooltipContent}
</div>,
document.body,
)}
{createPortal(
<div
ref={tooltipRef}
className={clsx(styles.tooltip, styles[placement], tooltipClassName, {
[styles.visible]: isVisible,
})}
style={{ ...tooltipStyles, ...tooltipStyle }}
>
{tooltipContent}
</div>,
document.body,
)}
</>
);
});

0 comments on commit ccca3cc

Please sign in to comment.