Skip to content

Commit

Permalink
fix: table first render width, close #5075 #4993
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Dec 27, 2021
1 parent 0bc1e0a commit b265d75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions components/vc-table/Body/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
15 changes: 11 additions & 4 deletions components/vc-table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit b265d75

Please sign in to comment.