fix: modal will automatically close when configing fields to association field details in sub-table (#2371)
This commit is contained in:
parent
4e4c4eae27
commit
cfa252bfb0
@ -1,9 +1,9 @@
|
||||
import { css } from '@emotion/css';
|
||||
import { FormItem, FormLayout } from '@formily/antd-v5';
|
||||
import { RecursionField, observer, useField, useFieldSchema } from '@formily/react';
|
||||
import { RecursionField, observer, useField, useFieldSchema, SchemaOptionsContext } from '@formily/react';
|
||||
import React, { useEffect } from 'react';
|
||||
import { CollectionProvider } from '../../../collection-manager';
|
||||
import { SchemaComponentOptions } from '../../../schema-component';
|
||||
import { useSchemaOptionsContext } from '../../../schema-component';
|
||||
import Select from '../select/Select';
|
||||
import { useAssociationFieldContext, useInsertSchema } from './hooks';
|
||||
import schema from './schema';
|
||||
@ -18,6 +18,14 @@ export const InternalSubTable = observer(
|
||||
insert(schema.SubTable);
|
||||
field.required = fieldSchema['required'];
|
||||
}, []);
|
||||
|
||||
const option = useSchemaOptionsContext();
|
||||
const components = {
|
||||
...option.components,
|
||||
FormItem: (props) => <FormItem {...props} />,
|
||||
'Radio.Group': Select,
|
||||
'Checkbox.Group': (props) => <Select multiple={true} mode="multiple" {...props} />,
|
||||
};
|
||||
return (
|
||||
<CollectionProvider name={options.target}>
|
||||
<FormLayout
|
||||
@ -39,11 +47,10 @@ export const InternalSubTable = observer(
|
||||
layout={'vertical'}
|
||||
bordered={false}
|
||||
>
|
||||
<SchemaComponentOptions
|
||||
components={{
|
||||
FormItem: (props) => <FormItem {...props} />,
|
||||
'Radio.Group': Select,
|
||||
'Checkbox.Group': (props) => <Select multiple={true} mode="multiple" {...props} />,
|
||||
<SchemaOptionsContext.Provider
|
||||
value={{
|
||||
scope: option.scope,
|
||||
components,
|
||||
}}
|
||||
>
|
||||
<RecursionField
|
||||
@ -54,7 +61,7 @@ export const InternalSubTable = observer(
|
||||
return s['x-component'] === 'AssociationField.SubTable';
|
||||
}}
|
||||
/>
|
||||
</SchemaComponentOptions>
|
||||
</SchemaOptionsContext.Provider>
|
||||
</FormLayout>
|
||||
</CollectionProvider>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user