- Notifications
You must be signed in to change notification settings - Fork1k
refactor: replace Popover with Tooltip in HelpTooltip#19635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
fba9492
e230f38
75c9fdf
bea24d8
9e6fa0c
303222b
f835cb1
dd7e233
d397fff
6134bad
ad562be
d30170c
4438af8
00b70ea
c59daf3
3aeaa49
eaf3baf
c93e092
ef6cceb
c142b5a
143e33e
d22a040
2ff9e66
ed5bf98
8f939f9
5050a92
ded8411
3466e90
3a8a403
5f79acc
b0696dd
71c1824
70e0dbf
1df04ec
6733d6a
bc12f84
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -3,18 +3,17 @@ import { | ||||||||
css, | ||||||||
type Interpolation, | ||||||||
type Theme, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 🙏 | ||||||||
} from "@emotion/react"; | ||||||||
import Link from "@mui/material/Link"; | ||||||||
import { Stack } from "components/Stack/Stack"; | ||||||||
import { | ||||||||
Tooltip, | ||||||||
TooltipContent, | ||||||||
type TooltipContentProps, | ||||||||
type TooltipProps, | ||||||||
TooltipProvider, | ||||||||
TooltipTrigger, | ||||||||
} from "components/Tooltip/Tooltip"; | ||||||||
import { CircleHelpIcon, ExternalLinkIcon } from "lucide-react"; | ||||||||
import { | ||||||||
type FC, | ||||||||
@@ -23,43 +22,50 @@ import { | ||||||||
type PropsWithChildren, | ||||||||
type ReactNode, | ||||||||
} from "react"; | ||||||||
import { cn } from "utils/cn"; | ||||||||
type Icon = typeof CircleHelpIcon; | ||||||||
type Size = "small" | "medium"; | ||||||||
export const HelpTooltipTrigger = TooltipTrigger; | ||||||||
export const HelpTooltipIcon = CircleHelpIcon; | ||||||||
export const HelpTooltip: FC<TooltipProps> = (props) => { | ||||||||
return ( | ||||||||
<TooltipProvider> | ||||||||
<Tooltip delayDuration={0} {...props} /> | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think 0 is probably too fast. what's the default here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. The default is 700 which feels very long. Worth mentioning that theMUI popover, which coder/site/src/components/deprecated/Popover/Popover.tsx Lines 130 to 132 in2030907
so I used a delay of 0 to keep consistency with our current UX There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. could we set it to like, 200? I feel like 0 is intense There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. No, 0 is exactly as intense as prod is rn: Screen.Recording.2025-09-04.at.4.05.34.PM.movI'm so used to 0 delay that 200 feels sluggish to me: Screen.Recording.2025-09-04.at.4.03.46.PM.mov | ||||||||
</TooltipProvider> | ||||||||
); | ||||||||
}; | ||||||||
export const HelpTooltipContent: FC<TooltipContentProps> = ({ | ||||||||
className, | ||||||||
...props | ||||||||
}) => { | ||||||||
return ( | ||||||||
<TooltipContent | ||||||||
side="bottom" | ||||||||
align="start" | ||||||||
collisionPadding={16} | ||||||||
{...props} | ||||||||
className={cn( | ||||||||
"w-[320px] p-5 bg-surface-secondary border-surface-quaternary text-sm", | ||||||||
className, | ||||||||
)} | ||||||||
/> | ||||||||
); | ||||||||
}; | ||||||||
typeHelpTooltipIconTriggerProps = HTMLAttributes<HTMLButtonElement> & { | ||||||||
size?: Size; | ||||||||
hoverEffect?: boolean; | ||||||||
}; | ||||||||
export constHelpTooltipIconTrigger = forwardRef< | ||||||||
HTMLButtonElement, | ||||||||
HelpTooltipIconTriggerProps | ||||||||
>((props, ref) => { | ||||||||
const { | ||||||||
size = "medium", | ||||||||
@@ -76,7 +82,7 @@ export const HelpTooltipTrigger = forwardRef< | ||||||||
}); | ||||||||
return ( | ||||||||
<HelpTooltipTrigger asChild> | ||||||||
<button | ||||||||
{...buttonProps} | ||||||||
aria-label="More info" | ||||||||
@@ -102,7 +108,7 @@ export const HelpTooltipTrigger = forwardRef< | ||||||||
> | ||||||||
{children} | ||||||||
</button> | ||||||||
</HelpTooltipTrigger> | ||||||||
); | ||||||||
}); | ||||||||
@@ -155,18 +161,12 @@ export const HelpTooltipAction: FC<HelpTooltipActionProps> = ({ | ||||||||
onClick, | ||||||||
ariaLabel, | ||||||||
}) => { | ||||||||
return ( | ||||||||
<button | ||||||||
type="button" | ||||||||
aria-label={ariaLabel ?? ""} | ||||||||
css={styles.action} | ||||||||
onClick={onClick} | ||||||||
> | ||||||||
<Icon css={styles.actionIcon} /> | ||||||||
{children} | ||||||||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import type { Meta, StoryObj } from "@storybook/react-vite"; | ||
import { expect,screen, userEvent, waitFor } from "storybook/test"; | ||
import { InfoTooltip } from "./InfoTooltip"; | ||
const meta = { | ||
@@ -16,13 +16,13 @@ export default meta; | ||
type Story = StoryObj<typeof InfoTooltip>; | ||
export const Example: Story = { | ||
play: async ({ step }) => { | ||
await step("activate hover trigger", async () => { | ||
await userEvent.hover(screen.getByRole("button")); | ||
await waitFor(() => | ||
expect(screen.getByRole("tooltip")).toHaveTextContent( | ||
meta.args.message, | ||
), | ||
Comment on lines +23 to +25 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Big fan of the more accessible selectors | ||
); | ||
}); | ||
}, | ||
@@ -33,13 +33,13 @@ export const Notice = { | ||
type: "notice", | ||
message: "Unfortunately, there's a radio connected to my brain", | ||
}, | ||
play: async ({ step }) => { | ||
await step("activate hover trigger", async () => { | ||
await userEvent.hover(screen.getByRole("button")); | ||
await waitFor(() => | ||
expect(screen.getByRole("tooltip")).toHaveTextContent( | ||
Notice.args.message, | ||
), | ||
); | ||
}); | ||
}, | ||
@@ -50,13 +50,13 @@ export const Warning = { | ||
type: "warning", | ||
message: "Unfortunately, there's a radio connected to my brain", | ||
}, | ||
play: async ({ step }) => { | ||
await step("activate hover trigger", async () => { | ||
await userEvent.hover(screen.getByRole("button")); | ||
await waitFor(() => | ||
expect(screen.getByRole("tooltip")).toHaveTextContent( | ||
Warning.args.message, | ||
), | ||
); | ||
}); | ||
}, | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.