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

pull/7302/head
HaiWei Lian 11 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); }, 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> { interface FilterConfig<RecordType> {
prefixCls: Ref<string>; prefixCls: Ref<string>;
dropdownPrefixCls: Ref<string>; dropdownPrefixCls: Ref<string>;
@ -202,7 +213,7 @@ interface FilterConfig<RecordType> {
function useFilter<RecordType>({ function useFilter<RecordType>({
prefixCls, prefixCls,
dropdownPrefixCls, dropdownPrefixCls,
mergedColumns, mergedColumns: rawMergedColumns,
locale, locale,
onFilterChange, onFilterChange,
getPopupContainer, getPopupContainer,
@ -211,6 +222,8 @@ function useFilter<RecordType>({
Ref<FilterState<RecordType>[]>, Ref<FilterState<RecordType>[]>,
Ref<Record<string, FilterValue | null>>, Ref<Record<string, FilterValue | null>>,
] { ] {
const mergedColumns = computed(() => getMergedColumns(rawMergedColumns.value));
const [filterStates, setFilterStates] = useState<FilterState<RecordType>[]>( const [filterStates, setFilterStates] = useState<FilterState<RecordType>[]>(
collectFilterStates(mergedColumns.value, true), collectFilterStates(mergedColumns.value, true),
); );

Loading…
Cancel
Save