Skip to content

Commit

Permalink
feat: add the ability to pass refs to Tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
haideralsh committed Nov 12, 2024
1 parent c8acc78 commit 9183e97
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Tooltip/Tooltip.story.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import { Button, Box, Link, Flex, Text, Tooltip } from "../index";
import styled from "styled-components";

export default {
title: "Components/Tooltip",
Expand Down Expand Up @@ -187,6 +186,16 @@ export const WithCustomComponent = () => (
</Tooltip>
);

export const WithRef = () => {
const ref = React.useRef(null);

return (
<Tooltip tooltip="I am a Tooltip!" ref={ref}>
<Button> Button </Button>
</Tooltip>
);
};

const CustomComponent = React.forwardRef<HTMLDivElement, { [key: string]: any }>((props, forwardedRef) => (
<span ref={forwardedRef} {...props}>
<Text inline>This component uses the forwardedRef from the Tooltip wrapping it</Text>
Expand Down
2 changes: 1 addition & 1 deletion src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { LegacyRef } from "react";
import React from "react";
import { Popper } from "../Popper";
import { generateId } from "../utils";
import TooltipContainer from "./TooltipContainer";
Expand Down

0 comments on commit 9183e97

Please sign in to comment.