This commit is contained in:
@@ -12,6 +12,7 @@ type FormSaveButtonProps = {
|
||||
formSelector?: string;
|
||||
formSelectors?: string[];
|
||||
label?: string;
|
||||
reloadDocumentOnSuccess?: boolean;
|
||||
};
|
||||
|
||||
function serializeForm(form: HTMLFormElement) {
|
||||
@@ -29,6 +30,7 @@ export function FormSaveButton({
|
||||
formSelector,
|
||||
formSelectors,
|
||||
label = "Speichern",
|
||||
reloadDocumentOnSuccess = false,
|
||||
}: FormSaveButtonProps) {
|
||||
const pathname = usePathname();
|
||||
const router = useRouter();
|
||||
@@ -220,6 +222,11 @@ export function FormSaveButton({
|
||||
}
|
||||
|
||||
pendingSubmissionRef.current = null;
|
||||
if (reloadDocumentOnSuccess) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
router.refresh();
|
||||
|
||||
if (!searchParams.has("__saved")) {
|
||||
@@ -233,7 +240,7 @@ export function FormSaveButton({
|
||||
router.replace(nextQuery ? `${pathname}?${nextQuery}` : pathname, {
|
||||
scroll: false,
|
||||
});
|
||||
}, [currentUrl, pathname, router, searchParams]);
|
||||
}, [currentUrl, pathname, reloadDocumentOnSuccess, router, searchParams]);
|
||||
|
||||
return (
|
||||
<Button type="submit" form={activeFormId ?? undefined} disabled={!activeFormId || !isDirty || isSubmitting}>
|
||||
|
||||
Reference in New Issue
Block a user