Skip to content

Commit 2a22135

Browse files
committed
fix: 🐛 pro-shadow-model reset loading
1 parent 00e44a5 commit 2a22135

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/pro-array-table/mixin.pro.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FormProvider, useField, useFieldSchema } from "@formily/react";
22
import { toJS } from "@formily/reactive";
3-
import React, { useContext, useEffect, useId, useRef } from "react";
3+
import React, { useContext, useEffect, useId, useRef, useState } from "react";
44
import { empty, omit, pick } from "../__builtins__";
55
import { Alert, BUTTON_TYPE, Button, Divider, Modal, Space } from "../adaptor";
66
import { ArrayBase } from "../adaptor/adaptor";
@@ -159,6 +159,7 @@ export const ArrayTableShowModal: React.FC<
159159
const pending = useRef(false);
160160
const ctx = useProArrayTableContext();
161161
const queryListCtx = useQueryListContext();
162+
const [loading, setLoading] = useState(false);
162163

163164
useEffect(() => {
164165
if (visible) {
@@ -188,6 +189,7 @@ export const ArrayTableShowModal: React.FC<
188189
}, 200);
189190
}).finally(() => {
190191
pending.current = false;
192+
setLoading(false);
191193
});
192194
};
193195

@@ -198,13 +200,20 @@ export const ArrayTableShowModal: React.FC<
198200
title={field.title}
199201
onCancel={() => {
200202
if (pending.current) return;
201-
return form
202-
.reset()
203-
.then(() => props?.onCancel?.(ctx, queryListCtx))
204-
.then(() => reset());
203+
setLoading(true);
204+
return Promise.resolve(props?.onCancel?.(ctx, queryListCtx)).then(() =>
205+
reset(),
206+
);
207+
}}
208+
cancelButtonProps={{
209+
loading,
210+
}}
211+
okButtonProps={{
212+
loading,
205213
}}
206214
onOk={() => {
207215
if (pending.current) return;
216+
setLoading(true);
208217
pending.current = true;
209218
return form
210219
.submit()

0 commit comments

Comments
 (0)