fix: clearFormGraph (#1706)

This commit is contained in:
katherinehhh 2023-04-14 21:57:44 +08:00 committed by GitHub
parent 0450789d63
commit 2e95d3bf85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,7 @@ const FormDecorator: React.FC<FormProps> = (props) => {
const getLinkageRules = (fieldSchema) => {
let linkageRules = null;
fieldSchema.mapProperties((schema) => {
console.log(schema);
if (schema['x-linkage-rules']) {
linkageRules = schema['x-linkage-rules'];
}
@ -70,10 +71,8 @@ const WithForm = (props) => {
const { form } = props;
const fieldSchema = useFieldSchema();
const { setFormValueChanged } = useActionContext();
const linkageRules = useMemo(
() => (getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || [],
[fieldSchema.properties?.grid?.['x-linkage-rules']],
);
const linkageRules =
(getLinkageRules(fieldSchema) || fieldSchema.parent?.['x-linkage-rules'])?.filter((k) => !k.disabled) || [];
useEffect(() => {
const id = uid();
form.addEffects(id, () => {
@ -119,7 +118,6 @@ const WithForm = (props) => {
useEffect(() => {
const id = uid();
const linkagefields = [];
const formGraph = form.getFormGraph();
form.addEffects(id, () => {
return linkageRules.map((v, index) => {
return v.actions?.map((h) => {
@ -142,8 +140,6 @@ const WithForm = (props) => {
});
return () => {
form.removeEffects(id);
form.clearFormGraph();
form.setFormGraph(formGraph);
};
}, [linkageRules]);
return fieldSchema['x-decorator'] === 'Form' ? <FormDecorator {...props} /> : <FormComponent {...props} />;