Skip to content

Commit b265d75

Browse files
committed
fix: table first render width, close #5075 #4993
1 parent 0bc1e0a commit b265d75

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

components/vc-table/Body/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
import type { GetRowKey, Key, GetComponentProps } from '../interface';
23
import ExpandedRow from './ExpandedRow';
34
import { getColumnsKey } from '../utils/valueUtil';

components/vc-table/Table.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,13 +449,20 @@ export default defineComponent<TableProps<DefaultRecordType>>({
449449
}
450450
};
451451
let timtout;
452+
const updateWidth = (width: number) => {
453+
if (width !== componentWidth.value) {
454+
triggerOnScroll();
455+
componentWidth.value = fullTableRef.value ? fullTableRef.value.offsetWidth : width;
456+
}
457+
};
452458
const onFullTableResize = ({ width }) => {
453459
clearTimeout(timtout);
460+
if (componentWidth.value === 0) {
461+
updateWidth(width);
462+
return;
463+
}
454464
timtout = setTimeout(() => {
455-
if (width !== componentWidth.value) {
456-
triggerOnScroll();
457-
componentWidth.value = fullTableRef.value ? fullTableRef.value.offsetWidth : width;
458-
}
465+
updateWidth(width);
459466
}, 100);
460467
};
461468

0 commit comments

Comments
 (0)