Skip to content

Commit

Permalink
fix: table reactive error, close #4756
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Oct 14, 2021
1 parent f64d7ad commit bd0bc08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
21 changes: 11 additions & 10 deletions components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,16 @@ const InteralTable = defineComponent<
return mergedData.value.slice((current - 1) * pageSize, current * pageSize);
});

const expandIconColumnIndex = computed(() => {
// Adjust expand icon index, no overwrite expandIconColumnIndex if set.
if (expandType.value === 'nest' && props.expandIconColumnIndex === undefined) {
return props.rowSelection ? 1 : 0;
} else if (props.expandIconColumnIndex! > 0 && props.rowSelection) {
return props.expandIconColumnIndex - 1;
}
return props.expandIconColumnIndex;
});

// ========================== Selections ==========================
const [transformSelectionColumns, selectedKeySet] = useSelection(
computed(() => props.rowSelection),
Expand All @@ -483,7 +493,7 @@ const InteralTable = defineComponent<
expandType,
childrenColumnName,
locale: tableLocale,
expandIconColumnIndex: computed(() => props.expandIconColumnIndex),
expandIconColumnIndex,
getPopupContainer: computed(() => props.getPopupContainer),
},
);
Expand All @@ -509,15 +519,6 @@ const InteralTable = defineComponent<
expose({
selectedKeySet,
});
const expandIconColumnIndex = computed(() => {
// Adjust expand icon index, no overwrite expandIconColumnIndex if set.
if (expandType.value === 'nest' && props.expandIconColumnIndex === undefined) {
return props.rowSelection ? 1 : 0;
} else if (props.expandIconColumnIndex! > 0 && props.rowSelection) {
return props.expandIconColumnIndex - 1;
}
return props.expandIconColumnIndex;
});

const indentSize = computed(() => {
// Indent size
Expand Down
19 changes: 10 additions & 9 deletions components/vc-table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -527,17 +527,18 @@ export default defineComponent<TableProps<DefaultRecordType>>({
summaryCollect,
}),
);

useProvideBody(
reactive({
...reactivePick(
props,
'rowClassName',
'expandedRowClassName',
'expandRowByClick',
'expandedRowRender',
'expandIconColumnIndex',
'indentSize',
...toRefs(
reactivePick(
props,
'rowClassName',
'expandedRowClassName',
'expandRowByClick',
'expandedRowRender',
'expandIconColumnIndex',
'indentSize',
),
),
columns,
flattenColumns,
Expand Down

0 comments on commit bd0bc08

Please sign in to comment.