From 5f4615f2c7c161c1f03904e093670d0f97827cae Mon Sep 17 00:00:00 2001 From: Arnei Date: Mon, 13 Apr 2026 16:34:22 +0200 Subject: [PATCH] Fix roles getting unselected in ACL tab In the access policy tab, when adding new roles, old roles would be removed. Basically, changing the roles in some manner would result in wonky behaviour. This patch fixes that, mostly by reverting 9d0a7b2203ee09e836bce57d08b230db87b2e32c and making sure the policy key id is more reliable than index. --- .../modals/ResourceDetailsAccessPolicyTab.tsx | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx index e23171dfc7..fdb1a86595 100644 --- a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx +++ b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx @@ -530,7 +530,7 @@ export const AccessPolicyTable = ({ {formik.values.policies.length > 0 && policiesFiltered.map( (policy, index) => ( - + {/* dropdown for policy.role */} {!transactions.readOnly ? ( @@ -547,11 +547,11 @@ export const AccessPolicyTable = ({ handleChange={element => { if (element) { const matchingRole = roles.find(role => role.name === element.value); - formik.setFieldValue(`policies.${index}.role`, element.value); - formik.setFieldValue( - `policies.${index}.user`, - matchingRole ? matchingRole.user : undefined, - ); + arrayHelpers.replace(formik.values.policies.findIndex(p => p === policy), { + ...policy, + role: element.value, + user: matchingRole ? matchingRole.user : undefined, + }); } }} placeholder={ @@ -591,7 +591,10 @@ export const AccessPolicyTable = ({ : "false" }`} onChange={(read: React.ChangeEvent) => - formik.setFieldValue(`policies.${index}.read`, read.target.checked) + arrayHelpers.replace(formik.values.policies.findIndex(p => p === policy), { + ...policy, + read: read.target.checked, + }) } /> @@ -615,7 +618,11 @@ export const AccessPolicyTable = ({ : "false" }`} onChange={(write: React.ChangeEvent) => - formik.setFieldValue(`policies.${index}.write`, write.target.checked) + arrayHelpers.replace(formik.values.policies.findIndex(p => p === policy), { + ...policy, + write: + write.target.checked, + }) } />