Skip to content

Commit

Permalink
fix(tooltip): prevent layout shift (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielrobertson authored Mar 20, 2023
1 parent cb1785e commit 5a2ed53
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/neat-beers-itch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@project44-manifest/react-tooltip': minor
---

fix tooltip layout shift
2 changes: 1 addition & 1 deletion packages/react/components/tooltip/src/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const Tooltip = React.forwardRef((props, forwardedRef) => {
<TooltipProvider
value={{ tooltipProps: { ...tooltipProps, ...positionProps }, tooltipRef, state }}
>
<Fade appear mountOnEnter unmountOnExit in={state.isOpen}>
<Fade appear mountOnEnter unmountOnExit in={state.isOpen} style={{ position: 'absolute' }}>
<TooltipContent {...other} ref={forwardedRef}>
{title}
</TooltipContent>
Expand Down
17 changes: 17 additions & 0 deletions packages/react/components/tooltip/stories/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,20 @@ export const Placement = () => (
</Tooltip>
</Stack>
);

export const IsOpen = () => (
<Stack css={{ marginTop: 56 }} gap="x-large" orientation="horizontal">
<Tooltip isOpen placement="bottom" title="bottom">
<Button>Hover Me</Button>
</Tooltip>
<Tooltip isOpen placement="left" title="left">
<Button>Hover Me</Button>
</Tooltip>
<Tooltip isOpen placement="right" title="right">
<Button>Hover Me</Button>
</Tooltip>
<Tooltip isOpen placement="top" title="top">
<Button>Hover Me</Button>
</Tooltip>
</Stack>
);

1 comment on commit 5a2ed53

@vercel
Copy link

@vercel vercel bot commented on 5a2ed53 Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.