Skip to content

Commit

Permalink
fix(FOROME-1236): change hasTooltip flag (#753)
Browse files Browse the repository at this point in the history
* fix(FOROME-1236): change hasTooltip flag

* fix(FOROME-1236): change hasTooltip flag

* fix(FOROME-1236): remove magic number
  • Loading branch information
EvgeniySobolev authored Jun 22, 2022
1 parent 0a9be87 commit 92d503b
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useRef } from 'react'
import { FC, useEffect, useRef, useState } from 'react'
import cn, { Argument } from 'classnames'
import Tooltip from 'rc-tooltip'

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

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

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

const hasTooltip = width + x > 230
useEffect(() => {
const container = datasetRef?.current
const isTooltipNeeded = container
? container.clientWidth < container.scrollWidth
: false

setHasTooltip(isTooltipNeeded)
}, [])

const fontColor = kind === null ? 'text-grey-blue' : 'text-white'
const fontWeight = isXL
Expand Down

0 comments on commit 92d503b

Please sign in to comment.