fix(components): [table] cell tooltip display error (#16868)

* fix(components): [table] cell tooltip diaplay error

* fix: update

* fix: update
This commit is contained in:
btea 2024-05-20 09:26:41 +08:00 committed by GitHub
parent 90c75710f3
commit ad0cd51796
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,10 @@ import type { TableColumnCtx } from '../table-column/defaults'
import type { TableBodyProps } from './defaults'
import type { TableOverflowTooltipOptions } from '../util'
function isGreaterThan(a: number, b: number, epsilon = 0.01) {
return a - b > epsilon
}
function useEvents<T>(props: Partial<TableBodyProps<T>>) {
const parent = inject(TABLE_INJECTION_KEY)
const tooltipContent = ref('')
@ -131,8 +135,8 @@ function useEvents<T>(props: Partial<TableBodyProps<T>>) {
* - Expected: 188
* - Actual: 188.00000762939453
*/
let rangeWidth = range.getBoundingClientRect().width
let rangeHeight = range.getBoundingClientRect().height
let { width: rangeWidth, height: rangeHeight } =
range.getBoundingClientRect()
const offsetWidth = rangeWidth - Math.floor(rangeWidth)
const { width: cellChildWidth, height: cellChildHeight } =
cellChild.getBoundingClientRect()
@ -148,9 +152,11 @@ function useEvents<T>(props: Partial<TableBodyProps<T>>) {
const horizontalPadding = left + right
const verticalPadding = top + bottom
if (
rangeWidth + horizontalPadding > cellChildWidth ||
rangeHeight + verticalPadding > cellChildHeight ||
cellChild.scrollWidth > cellChildWidth
isGreaterThan(rangeWidth + horizontalPadding, cellChildWidth) ||
isGreaterThan(rangeHeight + verticalPadding, cellChildHeight) ||
// When using a high-resolution screen, it is possible that a returns cellChild.scrollWidth value of 1921 and
// cellChildWidth returns a value of 1920.994140625. #16856 #16673
isGreaterThan(cellChild.scrollWidth, cellChildWidth)
) {
createTablePopper(
tooltipOptions,