Skip to content

Commit 14c128d

Browse files
committed
feat: integrate AutoScrollArea into Tooltip component for improved content scrolling
1 parent aaca728 commit 14c128d

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/components/tooltip/Tooltip.style.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
z-index: 999;
1010
padding: variables.$xxs variables.$xs;
11+
box-sizing: border-box;
12+
// clamp to the space the popper has left on screen; the inner
13+
// auto scroll area shrinks with it and takes over scrolling
14+
max-height: var(--radix-popper-available-height, 100vh);
15+
display: flex;
16+
flex-direction: column;
1117

1218
& {
1319
@include box.box(variables.$tertiary);

src/components/tooltip/Tooltip.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import {Color, ComponentProps, mergeComponentProps} from "../../utils";
33
import * as RadixTooltip from "@radix-ui/react-tooltip";
44
import "./Tooltip.style.scss"
5+
import {AutoScrollArea} from "../scroll-area/ScrollArea";
56

67
export type TooltipProps = ComponentProps & RadixTooltip.TooltipProps
78
export type TooltipTriggerProps = ComponentProps & RadixTooltip.TooltipTriggerProps
@@ -24,8 +25,13 @@ export const TooltipPortal: React.FC<TooltipPortalProps> = (props) => {
2425
}
2526

2627
export const TooltipContent: React.FC<TooltipContentProps> = (props) => {
28+
const {children, ...rest} = props
2729
return <RadixTooltip.TooltipContent
28-
align={props.align} {...mergeComponentProps(`tooltip__content tooltip__content--${props.color ?? "tertiary"}`, props) as TooltipContentProps}/>
30+
align={props.align} {...mergeComponentProps(`tooltip__content tooltip__content--${props.color ?? "tertiary"}`, rest) as TooltipContentProps}>
31+
<AutoScrollArea>
32+
{children}
33+
</AutoScrollArea>
34+
</RadixTooltip.TooltipContent>
2935
}
3036

3137
export const TooltipArrow: React.FC<TooltipArrowProps> = (props) => {

0 commit comments

Comments
 (0)