From 0924ddfa80cce7f2343b10bd255a488ab1c9ff28 Mon Sep 17 00:00:00 2001 From: Katherine Date: Fri, 27 Sep 2024 08:52:06 +0800 Subject: [PATCH] fix: after success setting for the submit button (#5332) * fix: submit action should support after uccess setting * fix: after success --- packages/core/client/src/block-provider/hooks/index.ts | 7 +++++++ .../schema-component/antd/action/Action.Designer.tsx | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/core/client/src/block-provider/hooks/index.ts b/packages/core/client/src/block-provider/hooks/index.ts index e5b5f370c8..2de2652ac6 100644 --- a/packages/core/client/src/block-provider/hooks/index.ts +++ b/packages/core/client/src/block-provider/hooks/index.ts @@ -251,6 +251,13 @@ export const useCreateActionProps = () => { if (!onSuccess?.successMessage) { message.success(t('Saved successfully')); await resetFormCorrectly(form); + if (onSuccess?.redirecting && onSuccess?.redirectTo) { + if (isURL(onSuccess.redirectTo)) { + window.location.href = onSuccess.redirectTo; + } else { + navigate(onSuccess.redirectTo); + } + } return; } if (onSuccess?.manualClose) { diff --git a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx index 441cd653e6..c7432d2002 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.Designer.tsx @@ -8,7 +8,7 @@ */ import { ArrayTable } from '@formily/antd-v5'; -import { Field, onFieldValueChange } from '@formily/core'; +import { onFieldValueChange } from '@formily/core'; import { ISchema, useField, useFieldSchema, useForm, useFormEffects } from '@formily/react'; import { isValid, uid } from '@formily/shared'; import { Alert, Flex, ModalProps, Tag } from 'antd'; @@ -258,7 +258,13 @@ export function AfterSuccess() { return (