diff --git a/src/Body/MeasureCell.tsx b/src/Body/MeasureCell.tsx index c90ae34d4..fb92f151b 100644 --- a/src/Body/MeasureCell.tsx +++ b/src/Body/MeasureCell.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import ResizeObserver from '@rc-component/resize-observer'; import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; +import { cleanMeasureRowAttributes } from '../utils/measureUtil'; export interface MeasureCellProps { columnKey: React.Key; @@ -12,12 +13,17 @@ const MeasureCell: React.FC = props => { const { columnKey, onColumnResize, title } = props; const cellRef = React.useRef(null); + const contentRef = React.useRef(null); useLayoutEffect(() => { if (cellRef.current) { onColumnResize(columnKey, cellRef.current.offsetWidth); } - }, []); + + if (contentRef.current) { + cleanMeasureRowAttributes(contentRef.current); + } + }, [title, columnKey, onColumnResize]); return ( @@ -25,7 +31,9 @@ const MeasureCell: React.FC = props => { ref={cellRef} style={{ paddingTop: 0, paddingBottom: 0, borderTop: 0, borderBottom: 0, height: 0 }} > -
{title || '\xa0'}
+
+ {title || '\xa0'} +
); diff --git a/src/Body/MeasureRow.tsx b/src/Body/MeasureRow.tsx index 1211839c6..147a50f66 100644 --- a/src/Body/MeasureRow.tsx +++ b/src/Body/MeasureRow.tsx @@ -40,6 +40,7 @@ const MeasureRow: React.FC = ({ const titleForMeasure = React.isValidElement>(rawTitle) ? React.cloneElement(rawTitle, { ref: null }) : rawTitle; + return ( { + FILTERED_ATTRIBUTES.forEach(attr => { + el.removeAttribute(attr); + }); + }); +}