diff --git a/packages/components/table/src/table-body/events-helper.ts b/packages/components/table/src/table-body/events-helper.ts index 4bb1fdc220..54cd11e18f 100644 --- a/packages/components/table/src/table-body/events-helper.ts +++ b/packages/components/table/src/table-body/events-helper.ts @@ -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(props: Partial>) { const parent = inject(TABLE_INJECTION_KEY) const tooltipContent = ref('') @@ -131,8 +135,8 @@ function useEvents(props: Partial>) { * - 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(props: Partial>) { 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,