refactor: validate required fields before showing confirmation dialog (#6931)

This commit is contained in:
Katherine 2025-05-27 22:24:42 +08:00 committed by GitHub
parent 21d7acd74e
commit 40d36af75b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -416,12 +416,12 @@ const RenderButton = ({
const { t } = useTranslation();
const { isPopupVisibleControlledByURL } = usePopupSettings();
const { openPopup } = usePopupUtils();
const form = useForm();
const openPopupRef = useRef(null);
openPopupRef.current = openPopup;
const handleButtonClick = useCallback(
(e: React.MouseEvent, checkPortal = true) => {
async (e: React.MouseEvent, checkPortal = true) => {
if (checkPortal && isPortalInBody(e.target as Element)) {
return;
}
@ -454,6 +454,7 @@ const RenderButton = ({
}
};
if (confirm?.enable !== false && confirm?.content) {
await form?.submit?.();
modal.confirm({
title: t(confirm.title, { title: confirmTitle || title || field?.title }),
content: t(confirm.content, { title: confirmTitle || title || field?.title }),