Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(QueryFilter): 修复 ProFormDependency 在 QueryFilter 中失效的问题 #8212

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading