From 1d942d9910f3230d6e92e147c436264f9e07d187 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sun, 16 Jul 2023 16:58:31 +0800 Subject: [PATCH] fix: loading did not disappear after submission failure (#2252) --- .../src/collection-manager/action-hooks.ts | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/core/client/src/collection-manager/action-hooks.ts b/packages/core/client/src/collection-manager/action-hooks.ts index 5fdb2d41c..8cf240c3f 100644 --- a/packages/core/client/src/collection-manager/action-hooks.ts +++ b/packages/core/client/src/collection-manager/action-hooks.ts @@ -332,14 +332,18 @@ export const useCreateAction = () => { const { resource } = useResourceContext(); return { async run() { - await form.submit(); - field.data = field.data || {}; - field.data.loading = true; - await resource.create({ values: form.values }); - ctx.setVisible(false); - await form.reset(); - field.data.loading = false; - refresh(); + try { + await form.submit(); + field.data = field.data || {}; + field.data.loading = true; + await resource.create({ values: form.values }); + ctx.setVisible(false); + await form.reset(); + field.data.loading = false; + refresh(); + } catch (error) { + field.data.loading=false; + } }, }; };