fix: table first render width, close #5075 #4993

pull/5084/head
tangjinzhou 3 years ago
parent 0bc1e0a620
commit b265d75c9a

@ -1,3 +1,4 @@
// base rc-table@7.17.2
import type { GetRowKey, Key, GetComponentProps } from '../interface';
import ExpandedRow from './ExpandedRow';
import { getColumnsKey } from '../utils/valueUtil';

@ -449,13 +449,20 @@ export default defineComponent<TableProps<DefaultRecordType>>({
}
};
let timtout;
const updateWidth = (width: number) => {
if (width !== componentWidth.value) {
triggerOnScroll();
componentWidth.value = fullTableRef.value ? fullTableRef.value.offsetWidth : width;
}
};
const onFullTableResize = ({ width }) => {
clearTimeout(timtout);
if (componentWidth.value === 0) {
updateWidth(width);
return;
}
timtout = setTimeout(() => {
if (width !== componentWidth.value) {
triggerOnScroll();
componentWidth.value = fullTableRef.value ? fullTableRef.value.offsetWidth : width;
}
updateWidth(width);
}, 100);
};

Loading…
Cancel
Save