Skip to content

Commit ab80ea5

Browse files
authored
🏷️ Allow ReactNode as title in Tooltip (#3460)
1 parent df03b24 commit ab80ea5

File tree

1 file changed

+4
-3
lines changed
  • packages/eds-core-react/src/components/Tooltip

1 file changed

+4
-3
lines changed

packages/eds-core-react/src/components/Tooltip/Tooltip.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
cloneElement,
88
useMemo,
99
useEffect,
10+
ReactNode,
1011
} from 'react'
1112
import { createPortal } from 'react-dom'
1213
import styled from 'styled-components'
@@ -81,7 +82,7 @@ export type TooltipProps = {
8182
/** Tooltip placement relative to anchor */
8283
placement?: Placement
8384
/** Tooltip title */
84-
title?: string
85+
title?: ReactNode
8586
/** Tooltip anchor element */
8687
children: React.ReactElement & React.RefAttributes<HTMLElement>
8788
/** Delay in ms, default 100 */
@@ -90,7 +91,7 @@ export type TooltipProps = {
9091
* @default document.body
9192
* */
9293
portalContainer?: HTMLElement
93-
} & HTMLAttributes<HTMLDivElement>
94+
} & Omit<HTMLAttributes<HTMLDivElement>, 'title'>
9495

9596
export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
9697
function Tooltip(
@@ -107,8 +108,8 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
107108
) {
108109
const arrowRef = useRef<HTMLDivElement>(null)
109110
const [open, setOpen] = useState(false)
110-
const shouldOpen = title !== '' && typeof document !== 'undefined'
111111
const { rootElement } = useEds()
112+
const shouldOpen = Boolean(title) && typeof document !== 'undefined'
112113

113114
const {
114115
x,

0 commit comments

Comments
 (0)