Skip to content

Commit bd0bc08

Browse files
committed
fix: table reactive error, close #4756
1 parent f64d7ad commit bd0bc08

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

components/table/Table.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,16 @@ const InteralTable = defineComponent<
471471
return mergedData.value.slice((current - 1) * pageSize, current * pageSize);
472472
});
473473

474+
const expandIconColumnIndex = computed(() => {
475+
// Adjust expand icon index, no overwrite expandIconColumnIndex if set.
476+
if (expandType.value === 'nest' && props.expandIconColumnIndex === undefined) {
477+
return props.rowSelection ? 1 : 0;
478+
} else if (props.expandIconColumnIndex! > 0 && props.rowSelection) {
479+
return props.expandIconColumnIndex - 1;
480+
}
481+
return props.expandIconColumnIndex;
482+
});
483+
474484
// ========================== Selections ==========================
475485
const [transformSelectionColumns, selectedKeySet] = useSelection(
476486
computed(() => props.rowSelection),
@@ -483,7 +493,7 @@ const InteralTable = defineComponent<
483493
expandType,
484494
childrenColumnName,
485495
locale: tableLocale,
486-
expandIconColumnIndex: computed(() => props.expandIconColumnIndex),
496+
expandIconColumnIndex,
487497
getPopupContainer: computed(() => props.getPopupContainer),
488498
},
489499
);
@@ -509,15 +519,6 @@ const InteralTable = defineComponent<
509519
expose({
510520
selectedKeySet,
511521
});
512-
const expandIconColumnIndex = computed(() => {
513-
// Adjust expand icon index, no overwrite expandIconColumnIndex if set.
514-
if (expandType.value === 'nest' && props.expandIconColumnIndex === undefined) {
515-
return props.rowSelection ? 1 : 0;
516-
} else if (props.expandIconColumnIndex! > 0 && props.rowSelection) {
517-
return props.expandIconColumnIndex - 1;
518-
}
519-
return props.expandIconColumnIndex;
520-
});
521522

522523
const indentSize = computed(() => {
523524
// Indent size

components/vc-table/Table.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -527,17 +527,18 @@ export default defineComponent<TableProps<DefaultRecordType>>({
527527
summaryCollect,
528528
}),
529529
);
530-
531530
useProvideBody(
532531
reactive({
533-
...reactivePick(
534-
props,
535-
'rowClassName',
536-
'expandedRowClassName',
537-
'expandRowByClick',
538-
'expandedRowRender',
539-
'expandIconColumnIndex',
540-
'indentSize',
532+
...toRefs(
533+
reactivePick(
534+
props,
535+
'rowClassName',
536+
'expandedRowClassName',
537+
'expandRowByClick',
538+
'expandedRowRender',
539+
'expandIconColumnIndex',
540+
'indentSize',
541+
),
541542
),
542543
columns,
543544
flattenColumns,

0 commit comments

Comments
 (0)