From f363c07afaa6e37456f2118e4c830043a3b8d523 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 20 Oct 2026 09:36:34 -0400 Subject: [PATCH] Fix form resetting --- .../PolicyAuthStackSectionEdit.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/resource-policy/PolicyAuthStackSectionEdit.tsx b/src/components/resource-policy/PolicyAuthStackSectionEdit.tsx index 42b546978..9371307b6 100644 --- a/src/components/resource-policy/PolicyAuthStackSectionEdit.tsx +++ b/src/components/resource-policy/PolicyAuthStackSectionEdit.tsx @@ -34,7 +34,6 @@ import { useTranslations } from "next-intl"; import { useRouter } from "next/navigation"; import { toUnicode } from "punycode"; import { - useActionState, useContext, useEffect, useMemo, @@ -291,9 +290,23 @@ export function PolicyAuthStackSectionEdit({ } }, [isInferenceResource, form]); - const [, formAction, isSubmitting] = useActionState(onSubmit, null); + const [isSubmitting, setIsSubmitting] = useState(false); const [isSavingOverlay, setIsSavingOverlay] = useState(false); + // Not using
: React 19 resets the form after the action + // completes, and Radix Switch listens for that reset and flips controlled + // switches (e.g. SSO) back to their initial value. + async function handleSubmit(e: React.FormEvent) { + e.preventDefault(); + if (isSubmitting) return; + setIsSubmitting(true); + try { + await onSubmit(); + } finally { + setIsSubmitting(false); + } + } + async function onSubmit() { if (readonly && !isResourceOverlay) return; @@ -550,7 +563,7 @@ export function PolicyAuthStackSectionEdit({ return ( - +