Skip to content

Commit 92d503b

Browse files
fix(FOROME-1236): change hasTooltip flag (#753)
* fix(FOROME-1236): change hasTooltip flag * fix(FOROME-1236): change hasTooltip flag * fix(FOROME-1236): remove magic number
1 parent 0a9be87 commit 92d503b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/pages/main/components/sidebar/datasets-list/components/dataset-name.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useRef } from 'react'
1+
import { FC, useEffect, useRef, useState } from 'react'
22
import cn, { Argument } from 'classnames'
33
import Tooltip from 'rc-tooltip'
44

@@ -28,10 +28,16 @@ export const DatasetName: FC<IDsNameProps> = ({
2828

2929
const name = isXL && /^xl_.*/i.test(dsName) ? dsName.substring(3) : dsName
3030

31-
const { x = 0, width = 0 } =
32-
datasetRef?.current?.getBoundingClientRect() || {}
31+
const [hasTooltip, setHasTooltip] = useState<boolean>(false)
3332

34-
const hasTooltip = width + x > 230
33+
useEffect(() => {
34+
const container = datasetRef?.current
35+
const isTooltipNeeded = container
36+
? container.clientWidth < container.scrollWidth
37+
: false
38+
39+
setHasTooltip(isTooltipNeeded)
40+
}, [])
3541

3642
const fontColor = kind === null ? 'text-grey-blue' : 'text-white'
3743
const fontWeight = isXL

0 commit comments

Comments
 (0)