Skip to content

Commit

Permalink
Merge branch 'main' into preset-font-family-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tenphi authored Aug 10, 2022
2 parents 475f1df + 34fdefb commit 0b7b936
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-zebras-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cube-dev/ui-kit": patch
---

Fixes `childrenchildrenchildren` bug when use `TooltipProvider` component
19 changes: 15 additions & 4 deletions src/components/overlays/Tooltip/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export default {
},
} as ComponentMeta<typeof Button>;

const timeout = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));

const Template: Story<CubeTooltipTriggerProps> = (args) => (
<TooltipTrigger {...args}>
<Button>Hover to show a tooltip</Button>
Expand Down Expand Up @@ -45,26 +48,34 @@ Default.play = async ({ canvasElement }) => {
export const ViaProvider: typeof ViaProviderTemplate = ViaProviderTemplate.bind(
{},
);
ViaProvider.args = {};
ViaProvider.args = {
delay: 0,
};
ViaProvider.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
// wait for TooltipProvider setRendered to true
await timeout(1000);

const button = await canvas.findByRole('button');
// this is a weird hack that makes tooltip working properly on page load
await userEvent.unhover(button);
await userEvent.hover(button);

await waitFor(() => expect(canvas.getByRole('tooltip')).toBeInTheDocument());
await waitFor(() => expect(canvas.getByRole('tooltip')).toBeVisible());
};

export const ViaProviderWithActiveWrap: typeof ViaProviderTemplate =
ViaProviderTemplate.bind({});
ViaProviderWithActiveWrap.args = { activeWrap: true };
ViaProviderWithActiveWrap.args = { activeWrap: true, delay: 0 };
ViaProviderWithActiveWrap.play = async ({ canvasElement }) => {
const canvas = within(canvasElement);
// wait for TooltipProvider setRendered to true
await timeout(1000);

const button = await canvas.findByRole('button');
// this is a weird hack that makes tooltip working properly on page load
await userEvent.unhover(button);
await userEvent.hover(button);

await waitFor(() => expect(canvas.getByRole('tooltip')).toBeInTheDocument());
await waitFor(() => expect(canvas.getByRole('tooltip')).toBeVisible());
};
2 changes: 1 addition & 1 deletion src/components/overlays/Tooltip/TooltipProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function TooltipProvider(props: CubeTooltipProviderProps) {
</Tooltip>
</TooltipTrigger>
) : (
<>children</>
<>{children}</>
);
}

Expand Down

0 comments on commit 0b7b936

Please sign in to comment.