Skip to content

Commit

Permalink
fix(QueryFilter): 修复 ProFormDependency 在 QueryFilter 中失效的问题 (#8212)
Browse files Browse the repository at this point in the history
  • Loading branch information
xliez authored Mar 11, 2024
1 parent b14a197 commit fdc5418
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions packages/form/src/layouts/QueryFilter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,12 @@ export type BaseQueryFilterProps = Omit<
const flatMapItems = (
items: React.ReactNode[],
ignoreRules?: boolean,
form?: FormInstance,
): React.ReactNode[] => {
return items?.flatMap((item: any) => {
if (item?.type.displayName === 'ProForm-Group' && !item.props?.title) {
return item.props.children;
}
if (item?.type.displayName === 'ProFormDependency' && !item.props?.title) {
const values = item.props.name.reduce((current: any, next: any) => {
return {
...current,
[next]: form?.getFieldValue(next),
};
}, {});
return item.props.children(values);
}

if (ignoreRules && React.isValidElement(item)) {
return React.cloneElement(item, {
...(item.props as any),
Expand Down Expand Up @@ -290,7 +281,6 @@ const QueryFilterContent: React.FC<{
showLength,
searchGutter,
showHiddenNum,
form,
} = props;

const submitter = useMemo(() => {
Expand Down Expand Up @@ -330,7 +320,7 @@ const QueryFilterContent: React.FC<{
let currentSpan = 0;

// 处理过,包含是否需要隐藏的 数组
const processedList = flatMapItems(items, props.ignoreRules, form).map(
const processedList = flatMapItems(items, props.ignoreRules).map(
(
item,
index,
Expand Down

0 comments on commit fdc5418

Please sign in to comment.