fix: table reactive error, close #4756

pull/4773/head
tangjinzhou 3 years ago
parent f64d7adb22
commit bd0bc086c1

@ -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),
@ -483,7 +493,7 @@ const InteralTable = defineComponent<
expandType,
childrenColumnName,
locale: tableLocale,
expandIconColumnIndex: computed(() => props.expandIconColumnIndex),
expandIconColumnIndex,
getPopupContainer: computed(() => props.getPopupContainer),
},
);
@ -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

@ -527,10 +527,10 @@ export default defineComponent<TableProps<DefaultRecordType>>({
summaryCollect,
}),
);
useProvideBody(
reactive({
...reactivePick(
...toRefs(
reactivePick(
props,
'rowClassName',
'expandedRowClassName',
@ -539,6 +539,7 @@ export default defineComponent<TableProps<DefaultRecordType>>({
'expandIconColumnIndex',
'indentSize',
),
),
columns,
flattenColumns,
tableLayout: mergedTableLayout,

Loading…
Cancel
Save