Skip to content

Commit

Permalink
fix: table rowSelection deep watch #4889
Browse files Browse the repository at this point in the history
close #4889
  • Loading branch information
tangjinzhou committed Nov 20, 2021
1 parent 3e05460 commit d129670
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions components/table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import defaultLocale from '../locale/en_US';
import type { SizeType } from '../config-provider';
import devWarning from '../vc-util/devWarning';
import type { PropType } from 'vue';
import { reactive, ref, computed, defineComponent, toRef, watchEffect } from 'vue';
import { reactive, ref, computed, defineComponent, toRef, watchEffect, watch } from 'vue';
import type { DefaultRecordType } from '../vc-table/interface';
import useBreakpoint from '../_util/hooks/useBreakpoint';
import useConfigInject from '../_util/hooks/useConfigInject';
Expand Down Expand Up @@ -487,23 +487,27 @@ const InteralTable = defineComponent<
}
return props.expandIconColumnIndex;
});

// ========================== Selections ==========================
const [transformSelectionColumns, selectedKeySet] = useSelection(
computed(() => props.rowSelection),
{
prefixCls,
data: mergedData,
pageData,
getRowKey,
getRecordByKey,
expandType,
childrenColumnName,
locale: tableLocale,
expandIconColumnIndex,
getPopupContainer: computed(() => props.getPopupContainer),
const rowSelection = ref();
watch(
() => props.rowSelection,
() => {
rowSelection.value = { ...props.rowSelection };
},
{ deep: true },
);
// ========================== Selections ==========================
const [transformSelectionColumns, selectedKeySet] = useSelection(rowSelection, {
prefixCls,
data: mergedData,
pageData,
getRowKey,
getRecordByKey,
expandType,
childrenColumnName,
locale: tableLocale,
expandIconColumnIndex,
getPopupContainer: computed(() => props.getPopupContainer),
});

const internalRowClassName = (record: any, index: number, indent: number) => {
let mergedRowClassName;
Expand Down
2 changes: 1 addition & 1 deletion components/table/hooks/useLazyKVMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function useLazyKVMap<RecordType>(
};
},
{
deep: false,
deep: true,
immediate: true,
},
);
Expand Down

0 comments on commit d129670

Please sign in to comment.