diff --git a/packages/components/table/src/table-body/events-helper.ts b/packages/components/table/src/table-body/events-helper.ts index e751934f66..0fe97c2d81 100644 --- a/packages/components/table/src/table-body/events-helper.ts +++ b/packages/components/table/src/table-body/events-helper.ts @@ -89,7 +89,13 @@ function useEvents(props: Partial>) { const range = document.createRange() range.setStart(cellChild, 0) range.setEnd(cellChild, cellChild.childNodes.length) - const rangeWidth = range.getBoundingClientRect().width + /** detail: https://github.com/element-plus/element-plus/issues/10790 + * What went wrong? + * UI > Browser > Zoom, In Blink/WebKit, getBoundingClientRect() sometimes returns inexact values, probably due to lost precision during internal calculations. In the example above: + * - Expected: 188 + * - Actual: 188.00000762939453 + */ + const rangeWidth = Math.round(range.getBoundingClientRect().width) const padding = (Number.parseInt(getStyle(cellChild, 'paddingLeft'), 10) || 0) + (Number.parseInt(getStyle(cellChild, 'paddingRight'), 10) || 0)