From 4b1d0a88bde36dbd2f818b250962eebfd3100c55 Mon Sep 17 00:00:00 2001 From: Yike Gao <83198150+gaoyikeshuer@users.noreply.github.com> Date: Wed, 1 Apr 2026 16:24:34 +0100 Subject: [PATCH] Fix save button inconsistent issue (#47686) Closes #47398 Signed-off-by: Yike Gao --- .../src/realm-settings/ClientProfileForm.tsx | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/js/apps/admin-ui/src/realm-settings/ClientProfileForm.tsx b/js/apps/admin-ui/src/realm-settings/ClientProfileForm.tsx index 2adc8715e15..3312fa4f37b 100644 --- a/js/apps/admin-ui/src/realm-settings/ClientProfileForm.tsx +++ b/js/apps/admin-ui/src/realm-settings/ClientProfileForm.tsx @@ -65,9 +65,8 @@ export default function ClientProfileForm() { const { handleSubmit, - setValue, getValues, - formState: { isDirty }, + formState: { isDirty, isValid }, control, } = form; @@ -95,6 +94,13 @@ export default function ClientProfileForm() { const editMode = profileName ? true : false; const [key, setKey] = useState(0); const reload = () => setKey(key + 1); + const setupForm = (profile?: ClientProfileRepresentation) => { + form.reset({ + name: profile?.name ?? "", + description: profile?.description ?? "", + executors: profile?.executors ?? [], + }); + }; useFetch( () => @@ -109,15 +115,8 @@ export default function ClientProfileForm() { ); const profile = profiles.profiles?.find((p) => p.name === profileName); setIsGlobalProfile(globalProfile !== undefined); - setValue("name", globalProfile?.name ?? profile?.name ?? ""); - setValue( - "description", - globalProfile?.description ?? profile?.description ?? "", - ); - setValue( - "executors", - globalProfile?.executors ?? profile?.executors ?? [], - ); + const source = globalProfile ?? profile; + setupForm(source); }, [key], ); @@ -244,7 +243,7 @@ export default function ClientProfileForm() { variant="primary" onClick={() => handleSubmit(save)()} data-testid="saveCreateProfile" - isDisabled={!isDirty} + isDisabled={!isValid} > {t("save")}