diff --git a/src/components/resource-policy/PolicyAuthStackSectionCreate.tsx b/src/components/resource-policy/PolicyAuthStackSectionCreate.tsx index 9553d8e57..f8d02fb30 100644 --- a/src/components/resource-policy/PolicyAuthStackSectionCreate.tsx +++ b/src/components/resource-policy/PolicyAuthStackSectionCreate.tsx @@ -207,19 +207,11 @@ export function PolicyAuthStackSectionCreate({ active={Boolean(emailWhitelistEnabled)} onConfigure={() => setEditingMethod("email")} onToggle={(active) => - handleToggle( - "email", - active, - () => - parentForm.setValue( - "emailWhitelistEnabled", - false - ), - () => - parentForm.setValue( - "emailWhitelistEnabled", - true - ) + handleToggle("email", active, () => + parentForm.setValue( + "emailWhitelistEnabled", + false + ) ) } disabled={!emailEnabled} @@ -266,12 +258,13 @@ export function PolicyAuthStackSectionCreate({ onOpenChange={(open) => !open && closeCredenza()} emailEnabled={emailEnabled} emails={emails} - onSave={(value) => + onSave={(value) => { parentForm.setValue( "emails", value as PolicyFormValues["emails"] - ) - } + ); + parentForm.setValue("emailWhitelistEnabled", true); + }} /> - handleToggle( - "email", - active, - () => - form.setValue( - "emailWhitelistEnabled", - false - ), - () => - form.setValue( - "emailWhitelistEnabled", - true - ) + handleToggle("email", active, () => + form.setValue( + "emailWhitelistEnabled", + false + ) ) } disabled={authReadonly || !emailEnabled} @@ -761,7 +753,10 @@ export function PolicyAuthStackSectionEdit({ emailEnabled={emailEnabled} disabled={authReadonly} emails={emails} - onSave={(value) => form.setValue("emails", value)} + onSave={(value) => { + form.setValue("emails", value); + form.setValue("emailWhitelistEnabled", true); + }} />