fix: linkage rule enable effect in form (#1669)
This commit is contained in:
parent
7821af4024
commit
a529d9b7eb
@ -6,6 +6,7 @@ import { ConfigProvider, Spin } from 'antd';
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import { useActionContext } from '..';
|
||||
import { useAttach, useComponent } from '../..';
|
||||
import { gridRowColWrap } from '../../../schema-initializer';
|
||||
import { useProps } from '../../hooks/useProps';
|
||||
import { linkageMergeAction } from './utils';
|
||||
|
||||
@ -69,8 +70,10 @@ const WithForm = (props) => {
|
||||
const { form } = props;
|
||||
const fieldSchema = useFieldSchema();
|
||||
const { setFormValueChanged } = useActionContext();
|
||||
const linkageRules =
|
||||
(getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || [];
|
||||
const linkageRules = useMemo(
|
||||
() => (getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || [],
|
||||
[fieldSchema.properties?.grid?.['x-linkage-rules']],
|
||||
);
|
||||
useEffect(() => {
|
||||
const id = uid();
|
||||
form.addEffects(id, () => {
|
||||
@ -114,7 +117,6 @@ const WithForm = (props) => {
|
||||
};
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (linkageRules.length > 0) {
|
||||
const id = uid();
|
||||
const linkagefields = [];
|
||||
const formGraph = form.getFormGraph();
|
||||
@ -143,7 +145,6 @@ const WithForm = (props) => {
|
||||
form.clearFormGraph();
|
||||
form.setFormGraph(formGraph);
|
||||
};
|
||||
}
|
||||
}, [linkageRules]);
|
||||
return fieldSchema['x-decorator'] === 'Form' ? <FormDecorator {...props} /> : <FormComponent {...props} />;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user