Skip to content

Commit e9793de

Browse files
authored
fix: add portal to tooltip component
1 parent 27675eb commit e9793de

File tree

3 files changed

+40
-57
lines changed

3 files changed

+40
-57
lines changed

components/Tooltip/Tooltip.tsx

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,33 +47,41 @@ export function Tooltip({
4747
return (
4848
<TooltipPrimitive.Root open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange}>
4949
<TooltipPrimitive.Trigger asChild>{children}</TooltipPrimitive.Trigger>
50-
51-
<Content css={css} side="top" align="center" sideOffset={5} {...props} multiline={multiline}>
52-
{isContentString ? (
53-
<Text
54-
size="1"
55-
as="p"
56-
css={{
57-
color: 'currentColor',
58-
lineHeight: multiline ? '20px' : undefined,
59-
}}
60-
>
61-
{content}
62-
</Text>
63-
) : (
64-
content
65-
)}
66-
<ArrowBox>
67-
<TooltipPrimitive.Arrow
68-
offset={5}
69-
width={11}
70-
height={5}
71-
style={{
72-
fill: 'currentColor',
73-
}}
74-
/>
75-
</ArrowBox>
76-
</Content>
50+
<TooltipPrimitive.Portal>
51+
<Content
52+
css={css}
53+
side="top"
54+
align="center"
55+
sideOffset={5}
56+
{...props}
57+
multiline={multiline}
58+
>
59+
{isContentString ? (
60+
<Text
61+
size="1"
62+
as="p"
63+
css={{
64+
color: 'currentColor',
65+
lineHeight: multiline ? '20px' : undefined,
66+
}}
67+
>
68+
{content}
69+
</Text>
70+
) : (
71+
content
72+
)}
73+
<ArrowBox>
74+
<TooltipPrimitive.Arrow
75+
offset={5}
76+
width={11}
77+
height={5}
78+
style={{
79+
fill: 'currentColor',
80+
}}
81+
/>
82+
</ArrowBox>
83+
</Content>
84+
</TooltipPrimitive.Portal>
7785
</TooltipPrimitive.Root>
7886
);
7987
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"@radix-ui/react-tabs": "^1.0.1",
8080
"@radix-ui/react-toggle": "^1.0.1",
8181
"@radix-ui/react-toggle-group": "^1.0.1",
82-
"@radix-ui/react-tooltip": "^1.0.2",
82+
"@radix-ui/react-tooltip": "^1.0.7",
8383
"@radix-ui/react-use-layout-effect": "^1.0.0",
8484
"@radix-ui/react-visually-hidden": "^1.0.1",
8585
"@rollup/plugin-babel": "^5.3.1",

yarn.lock

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@
26102610
"@radix-ui/react-separator" "1.0.3"
26112611
"@radix-ui/react-toggle-group" "1.0.4"
26122612

2613-
"@radix-ui/react-tooltip@^1.0.2":
2613+
"@radix-ui/react-tooltip@^1.0.7":
26142614
version "1.0.7"
26152615
resolved "https://registry.yarnpkg.com/@radix-ui/react-tooltip/-/react-tooltip-1.0.7.tgz#8f55070f852e7e7450cc1d9210b793d2e5a7686e"
26162616
integrity sha512-lPh5iKNFVQ/jav/j6ZrWq3blfDJ0OH9R6FlNUHPMqdLuQ9vwDgFsRxvl8b7Asuy5c8xmoojHUxKHQSOAvMHxyw==
@@ -12500,7 +12500,7 @@ string-length@^4.0.1:
1250012500
char-regex "^1.0.2"
1250112501
strip-ansi "^6.0.0"
1250212502

12503-
"string-width-cjs@npm:string-width@^4.2.0":
12503+
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
1250412504
version "4.2.3"
1250512505
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
1250612506
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -12518,15 +12518,6 @@ string-width@^1.0.1:
1251812518
is-fullwidth-code-point "^1.0.0"
1251912519
strip-ansi "^3.0.0"
1252012520

12521-
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
12522-
version "4.2.3"
12523-
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
12524-
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
12525-
dependencies:
12526-
emoji-regex "^8.0.0"
12527-
is-fullwidth-code-point "^3.0.0"
12528-
strip-ansi "^6.0.1"
12529-
1253012521
string-width@^2.1.0, string-width@^2.1.1:
1253112522
version "2.1.1"
1253212523
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
@@ -12594,7 +12585,7 @@ stringify-entities@^4.0.0:
1259412585
character-entities-html4 "^2.0.0"
1259512586
character-entities-legacy "^3.0.0"
1259612587

12597-
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
12588+
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
1259812589
version "6.0.1"
1259912590
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
1260012591
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -12622,13 +12613,6 @@ strip-ansi@^5.1.0:
1262212613
dependencies:
1262312614
ansi-regex "^4.1.0"
1262412615

12625-
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
12626-
version "6.0.1"
12627-
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
12628-
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
12629-
dependencies:
12630-
ansi-regex "^5.0.1"
12631-
1263212616
strip-ansi@^7.0.1:
1263312617
version "7.1.0"
1263412618
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@@ -13688,7 +13672,7 @@ wordwrap@^1.0.0:
1368813672
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
1368913673
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==
1369013674

13691-
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
13675+
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
1369213676
version "7.0.0"
1369313677
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
1369413678
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@@ -13714,15 +13698,6 @@ wrap-ansi@^6.2.0:
1371413698
string-width "^4.1.0"
1371513699
strip-ansi "^6.0.0"
1371613700

13717-
wrap-ansi@^7.0.0:
13718-
version "7.0.0"
13719-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
13720-
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
13721-
dependencies:
13722-
ansi-styles "^4.0.0"
13723-
string-width "^4.1.0"
13724-
strip-ansi "^6.0.0"
13725-
1372613701
wrap-ansi@^8.1.0:
1372713702
version "8.1.0"
1372813703
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"

0 commit comments

Comments
 (0)