Skip to content

Commit db12afd

Browse files
committed
add wrapper on glossary tooltip to avoid text wrapping in a new line when tooltip is displayed
1 parent 8bf4efc commit db12afd

File tree

1 file changed

+24
-22
lines changed
  • src/components/Glossary/GlossaryTooltip

1 file changed

+24
-22
lines changed

src/components/Glossary/GlossaryTooltip/index.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ReactNode } from "react"
2-
import { Text, useBreakpointValue } from "@chakra-ui/react"
2+
import { Box, Text, useBreakpointValue } from "@chakra-ui/react"
33

44
import GlossaryDefinition from "@/components/Glossary/GlossaryDefinition"
55
import Tooltip from "@/components/Tooltip"
@@ -13,28 +13,30 @@ const GlossaryTooltip = ({ children, termKey }: GlossaryTooltipProps) => {
1313
const isLargeScreen = useBreakpointValue({ base: false, lg: true })
1414

1515
return isLargeScreen ? (
16-
<Tooltip
17-
content={
18-
<GlossaryDefinition
19-
term={termKey}
20-
size="sm"
21-
options={{ ns: "glossary-tooltip" }}
22-
/>
23-
}
24-
>
25-
<Text
26-
as="u"
27-
textDecorationStyle="dotted"
28-
textUnderlineOffset="3px"
29-
_hover={{
30-
textDecorationColor: "primary.hover",
31-
color: "primary.hover",
32-
}}
33-
cursor="help"
16+
<Box display="inline-block">
17+
<Tooltip
18+
content={
19+
<GlossaryDefinition
20+
term={termKey}
21+
size="sm"
22+
options={{ ns: "glossary-tooltip" }}
23+
/>
24+
}
3425
>
35-
{children}
36-
</Text>
37-
</Tooltip>
26+
<Text
27+
as="u"
28+
textDecorationStyle="dotted"
29+
textUnderlineOffset="3px"
30+
_hover={{
31+
textDecorationColor: "primary.hover",
32+
color: "primary.hover",
33+
}}
34+
cursor="help"
35+
>
36+
{children}
37+
</Text>
38+
</Tooltip>
39+
</Box>
3840
) : (
3941
<Text as="span">{children}</Text>
4042
)

0 commit comments

Comments
 (0)