fix(auto-tip): [auto-tip] fix bug that the checkbox always displays the tip (#2262)

This commit is contained in:
ajaxzheng 2024-10-14 21:07:35 +08:00 committed by GitHub
parent cb34b70e54
commit 2bfd5fd281
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -20,6 +20,9 @@ interface TooltipDirectiveConfig {
placement?: string
}
// 高度计算最多可以允许的误差修复checkbox的tip提示一直显示的bugscrollHeight15clientHeight14
const MISTAKE_VALUE = 2
/** v-auto-tip 绑定值。 支持 falsy值 或 TooltipDirectiveConfig 值, 当传入falsy值时表示禁用tooltip */
type BoundingValueType = undefined | false | TooltipDirectiveConfig
@ -32,7 +35,8 @@ const tooltipContent = hooks.ref('')
// 判断是否超出隐藏
const isEllipsis = (currentTarget) =>
currentTarget?.textContent &&
(currentTarget.scrollWidth > currentTarget.clientWidth || currentTarget.scrollHeight > currentTarget.clientHeight)
(currentTarget.scrollWidth > currentTarget.clientWidth ||
currentTarget.scrollHeight - currentTarget.clientHeight > MISTAKE_VALUE)
const isAlwaysShowTip = (currentTarget) => Boolean(currentTarget?.boundingValue?.always)