mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
fix: add ClearCollectionFieldContext (#4101)
* fix: add ClearCollectionFieldContext * chore: add comment --------- Co-authored-by: Zeke Zhang <958414905@qq.com>
This commit is contained in:
parent
cb91f7dbd4
commit
1bacd00739
@ -42,6 +42,10 @@ export const CollectionFieldProvider: FC<CollectionFieldProviderProps> = (props)
|
|||||||
return <CollectionFieldContext.Provider value={value}>{children}</CollectionFieldContext.Provider>;
|
return <CollectionFieldContext.Provider value={value}>{children}</CollectionFieldContext.Provider>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const ClearCollectionFieldContext: FC = (props) => {
|
||||||
|
return <CollectionFieldContext.Provider value={null}>{props.children}</CollectionFieldContext.Provider>;
|
||||||
|
};
|
||||||
|
|
||||||
export const useCollectionField = () => {
|
export const useCollectionField = () => {
|
||||||
const context = useContext(CollectionFieldContext);
|
const context = useContext(CollectionFieldContext);
|
||||||
// if (!context) {
|
// if (!context) {
|
||||||
|
@ -6,7 +6,7 @@ import { Space, message } from 'antd';
|
|||||||
import { isFunction } from 'mathjs';
|
import { isFunction } from 'mathjs';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { RecordProvider, useAPIClient, useCollectionRecordData } from '../../../';
|
import { ClearCollectionFieldContext, RecordProvider, useAPIClient, useCollectionRecordData } from '../../../';
|
||||||
import { isVariable } from '../../../variables/utils/isVariable';
|
import { isVariable } from '../../../variables/utils/isVariable';
|
||||||
import { getInnermostKeyAndValue } from '../../common/utils/uitls';
|
import { getInnermostKeyAndValue } from '../../common/utils/uitls';
|
||||||
import { RemoteSelect, RemoteSelectProps } from '../remote-select';
|
import { RemoteSelect, RemoteSelectProps } from '../remote-select';
|
||||||
@ -135,6 +135,8 @@ const InternalAssociationSelect = observer(
|
|||||||
|
|
||||||
{(addMode === 'modalAdd' || isAllowAddNew) && (
|
{(addMode === 'modalAdd' || isAllowAddNew) && (
|
||||||
<RecordProvider isNew={true} record={null} parent={recordData}>
|
<RecordProvider isNew={true} record={null} parent={recordData}>
|
||||||
|
{/* 快捷添加按钮添加的添加的是一个普通的 form 区块(非关系区块),不应该与任何字段有关联,所以在这里把字段相关的上下文给清除掉 */}
|
||||||
|
<ClearCollectionFieldContext>
|
||||||
<RecursionField
|
<RecursionField
|
||||||
onlyRenderProperties
|
onlyRenderProperties
|
||||||
basePath={field.address}
|
basePath={field.address}
|
||||||
@ -143,6 +145,7 @@ const InternalAssociationSelect = observer(
|
|||||||
return s['x-component'] === 'Action';
|
return s['x-component'] === 'Action';
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</ClearCollectionFieldContext>
|
||||||
</RecordProvider>
|
</RecordProvider>
|
||||||
)}
|
)}
|
||||||
</Space.Compact>
|
</Space.Compact>
|
||||||
|
@ -9,7 +9,13 @@ import {
|
|||||||
SchemaComponentOptions,
|
SchemaComponentOptions,
|
||||||
useActionContext,
|
useActionContext,
|
||||||
} from '../..';
|
} from '../..';
|
||||||
import { CollectionProvider_deprecated, RecordProvider, useFormBlockContext, useCollectionRecordData } from '../../../';
|
import {
|
||||||
|
ClearCollectionFieldContext,
|
||||||
|
CollectionProvider_deprecated,
|
||||||
|
RecordProvider,
|
||||||
|
useCollectionRecordData,
|
||||||
|
useFormBlockContext,
|
||||||
|
} from '../../../';
|
||||||
import {
|
import {
|
||||||
TableSelectorParamsProvider,
|
TableSelectorParamsProvider,
|
||||||
useTableSelectorProps as useTsp,
|
useTableSelectorProps as useTsp,
|
||||||
@ -171,6 +177,8 @@ export const InternalPicker = observer(
|
|||||||
</div>
|
</div>
|
||||||
{isAllowAddNew && (
|
{isAllowAddNew && (
|
||||||
<RecordProvider isNew record={null} parent={recordData}>
|
<RecordProvider isNew record={null} parent={recordData}>
|
||||||
|
{/* 快捷添加按钮添加的添加的是一个普通的 form 区块(非关系区块),不应该与任何字段有关联,所以在这里把字段相关的上下文给清除掉 */}
|
||||||
|
<ClearCollectionFieldContext>
|
||||||
<RecursionField
|
<RecursionField
|
||||||
onlyRenderProperties
|
onlyRenderProperties
|
||||||
basePath={field.address}
|
basePath={field.address}
|
||||||
@ -179,6 +187,7 @@ export const InternalPicker = observer(
|
|||||||
return s['x-component'] === 'Action';
|
return s['x-component'] === 'Action';
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
</ClearCollectionFieldContext>
|
||||||
</RecordProvider>
|
</RecordProvider>
|
||||||
)}
|
)}
|
||||||
</Input.Group>
|
</Input.Group>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user