From fdb7b4c664da5150b0792361c11f02a1ad37a48d Mon Sep 17 00:00:00 2001 From: Junyi Date: Tue, 28 Jun 2022 18:48:16 +0800 Subject: [PATCH] fix(plugin-workflow): clear options when change collection (#547) --- .vscode/launch.json | 2 +- .../core/client/src/workflow/triggers/collection.tsx | 11 +++++++++-- .../src/workflow/triggers/schedule/ScheduleConfig.tsx | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 4feb68bab..20cb42464 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -33,7 +33,7 @@ "test", "--runInBand", // could be any single file path to debug - "${workspaceFolder}/packages/" + "${workspaceFolder}/packages/plugins/workflow/src/__tests__/instructions/parallel.test.ts" ], "port": 9229, "skipFiles": [ diff --git a/packages/core/client/src/workflow/triggers/collection.tsx b/packages/core/client/src/workflow/triggers/collection.tsx index 5caa28c0f..f9e22d41c 100644 --- a/packages/core/client/src/workflow/triggers/collection.tsx +++ b/packages/core/client/src/workflow/triggers/collection.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Select } from 'antd'; -import { observer, useForm } from '@formily/react'; +import { observer, useForm, useFormEffects } from '@formily/react'; import { useCollectionDataSource, useCollectionManager } from '../../collection-manager'; import { useCompile } from '../../schema-component'; @@ -10,12 +10,19 @@ import { BaseTypeSet } from '../calculators'; import { collection, filter } from '../schemas/collection'; import { useTranslation } from 'react-i18next'; import { css } from '@emotion/css'; +import { onFieldValueChange } from '@formily/core'; const FieldsSelect = observer((props) => { const compile = useCompile(); const { getCollectionFields } = useCollectionManager(); - const { values } = useForm(); + const { values, clearFormGraph, setValuesIn } = useForm(); const fields = getCollectionFields(values?.config?.collection); + useFormEffects(() => { + onFieldValueChange('config.collection', (field) => { + clearFormGraph('config.changed'); + setValuesIn('config.condition', null); + }); + }); return (