mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 08:26:21 +00: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>;
|
||||
};
|
||||
|
||||
export const ClearCollectionFieldContext: FC = (props) => {
|
||||
return <CollectionFieldContext.Provider value={null}>{props.children}</CollectionFieldContext.Provider>;
|
||||
};
|
||||
|
||||
export const useCollectionField = () => {
|
||||
const context = useContext(CollectionFieldContext);
|
||||
// if (!context) {
|
||||
|
@ -6,7 +6,7 @@ import { Space, message } from 'antd';
|
||||
import { isFunction } from 'mathjs';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RecordProvider, useAPIClient, useCollectionRecordData } from '../../../';
|
||||
import { ClearCollectionFieldContext, RecordProvider, useAPIClient, useCollectionRecordData } from '../../../';
|
||||
import { isVariable } from '../../../variables/utils/isVariable';
|
||||
import { getInnermostKeyAndValue } from '../../common/utils/uitls';
|
||||
import { RemoteSelect, RemoteSelectProps } from '../remote-select';
|
||||
@ -135,14 +135,17 @@ const InternalAssociationSelect = observer(
|
||||
|
||||
{(addMode === 'modalAdd' || isAllowAddNew) && (
|
||||
<RecordProvider isNew={true} record={null} parent={recordData}>
|
||||
<RecursionField
|
||||
onlyRenderProperties
|
||||
basePath={field.address}
|
||||
schema={fieldSchema}
|
||||
filterProperties={(s) => {
|
||||
return s['x-component'] === 'Action';
|
||||
}}
|
||||
/>
|
||||
{/* 快捷添加按钮添加的添加的是一个普通的 form 区块(非关系区块),不应该与任何字段有关联,所以在这里把字段相关的上下文给清除掉 */}
|
||||
<ClearCollectionFieldContext>
|
||||
<RecursionField
|
||||
onlyRenderProperties
|
||||
basePath={field.address}
|
||||
schema={fieldSchema}
|
||||
filterProperties={(s) => {
|
||||
return s['x-component'] === 'Action';
|
||||
}}
|
||||
/>
|
||||
</ClearCollectionFieldContext>
|
||||
</RecordProvider>
|
||||
)}
|
||||
</Space.Compact>
|
||||
|
@ -9,7 +9,13 @@ import {
|
||||
SchemaComponentOptions,
|
||||
useActionContext,
|
||||
} from '../..';
|
||||
import { CollectionProvider_deprecated, RecordProvider, useFormBlockContext, useCollectionRecordData } from '../../../';
|
||||
import {
|
||||
ClearCollectionFieldContext,
|
||||
CollectionProvider_deprecated,
|
||||
RecordProvider,
|
||||
useCollectionRecordData,
|
||||
useFormBlockContext,
|
||||
} from '../../../';
|
||||
import {
|
||||
TableSelectorParamsProvider,
|
||||
useTableSelectorProps as useTsp,
|
||||
@ -171,14 +177,17 @@ export const InternalPicker = observer(
|
||||
</div>
|
||||
{isAllowAddNew && (
|
||||
<RecordProvider isNew record={null} parent={recordData}>
|
||||
<RecursionField
|
||||
onlyRenderProperties
|
||||
basePath={field.address}
|
||||
schema={fieldSchema}
|
||||
filterProperties={(s) => {
|
||||
return s['x-component'] === 'Action';
|
||||
}}
|
||||
/>
|
||||
{/* 快捷添加按钮添加的添加的是一个普通的 form 区块(非关系区块),不应该与任何字段有关联,所以在这里把字段相关的上下文给清除掉 */}
|
||||
<ClearCollectionFieldContext>
|
||||
<RecursionField
|
||||
onlyRenderProperties
|
||||
basePath={field.address}
|
||||
schema={fieldSchema}
|
||||
filterProperties={(s) => {
|
||||
return s['x-component'] === 'Action';
|
||||
}}
|
||||
/>
|
||||
</ClearCollectionFieldContext>
|
||||
</RecordProvider>
|
||||
)}
|
||||
</Input.Group>
|
||||
|
Loading…
Reference in New Issue
Block a user