mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-23 18:10:26 +08:00
revert: customtag tooltip delay (#5856)
This commit is contained in:
parent
6ee181ed38
commit
db6408f3b9
@ -1,6 +1,6 @@
|
|||||||
import { CloseOutlined } from '@ant-design/icons'
|
import { CloseOutlined } from '@ant-design/icons'
|
||||||
import { Tooltip } from 'antd'
|
import { Tooltip } from 'antd'
|
||||||
import { FC, memo, useEffect, useMemo, useState } from 'react'
|
import { FC, memo } from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
interface CustomTagProps {
|
interface CustomTagProps {
|
||||||
@ -14,29 +14,13 @@ interface CustomTagProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CustomTag: FC<CustomTagProps> = ({ children, icon, color, size = 12, tooltip, closable = false, onClose }) => {
|
const CustomTag: FC<CustomTagProps> = ({ children, icon, color, size = 12, tooltip, closable = false, onClose }) => {
|
||||||
const [showTooltip, setShowTooltip] = useState(false)
|
return (
|
||||||
|
<Tooltip title={tooltip} placement="top">
|
||||||
useEffect(() => {
|
|
||||||
const timer = setTimeout(() => setShowTooltip(true), 300)
|
|
||||||
return () => clearTimeout(timer)
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const tagContent = useMemo(
|
|
||||||
() => (
|
|
||||||
<Tag $color={color} $size={size} $closable={closable}>
|
<Tag $color={color} $size={size} $closable={closable}>
|
||||||
{icon && icon} {children}
|
{icon && icon} {children}
|
||||||
{closable && <CloseIcon $size={size} $color={color} onClick={onClose} />}
|
{closable && <CloseIcon $size={size} $color={color} onClick={onClose} />}
|
||||||
</Tag>
|
</Tag>
|
||||||
),
|
|
||||||
[children, color, closable, icon, onClose, size]
|
|
||||||
)
|
|
||||||
|
|
||||||
return tooltip && showTooltip ? (
|
|
||||||
<Tooltip title={tooltip} placement="top">
|
|
||||||
{tagContent}
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
) : (
|
|
||||||
tagContent
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user