fix: table filter does not work in header group (#7233)

pull/7302/head
HaiWei Lian 10 months ago committed by GitHub
parent d870f3f8e0
commit ad8d32ab09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -187,6 +187,17 @@ export function getFilterData<RecordType>(
}, data);
}
function getMergedColumns<RecordType>(
rawMergedColumns: ColumnsType<RecordType>,
): ColumnsType<RecordType> {
return rawMergedColumns.flatMap(column => {
if ('children' in column) {
return [column, ...getMergedColumns(column.children || [])];
}
return [column];
});
}
interface FilterConfig<RecordType> {
prefixCls: Ref<string>;
dropdownPrefixCls: Ref<string>;
@ -202,7 +213,7 @@ interface FilterConfig<RecordType> {
function useFilter<RecordType>({
prefixCls,
dropdownPrefixCls,
mergedColumns,
mergedColumns: rawMergedColumns,
locale,
onFilterChange,
getPopupContainer,
@ -211,6 +222,8 @@ function useFilter<RecordType>({
Ref<FilterState<RecordType>[]>,
Ref<Record<string, FilterValue | null>>,
] {
const mergedColumns = computed(() => getMergedColumns(rawMergedColumns.value));
const [filterStates, setFilterStates] = useState<FilterState<RecordType>[]>(
collectFilterStates(mergedColumns.value, true),
);

Loading…
Cancel
Save