From 9d0a7b2203ee09e836bce57d08b230db87b2e32c Mon Sep 17 00:00:00 2001 From: Arnei Date: Fri, 13 Mar 2026 10:59:34 +0100 Subject: [PATCH] Fix role getting unselected when changing write Fixes #1507. There is a bug in the access policy tab of event details that can be reproduced like so: 1. Add a new policy. 2. Set a role for the new policy. 3. Change the write rights for the new policy. The role is now unset. This patch should fix that. --- .../modals/ResourceDetailsAccessPolicyTab.tsx | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx index ed0d9b2b57..e23171dfc7 100644 --- a/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx +++ b/src/components/shared/modals/ResourceDetailsAccessPolicyTab.tsx @@ -547,11 +547,11 @@ export const AccessPolicyTable = ({ handleChange={element => { if (element) { const matchingRole = roles.find(role => role.name === element.value); - arrayHelpers.replace(formik.values.policies.findIndex(p => p === policy), { - ...policy, - role: element.value, - user: matchingRole ? matchingRole.user : undefined, - }); + formik.setFieldValue(`policies.${index}.role`, element.value); + formik.setFieldValue( + `policies.${index}.user`, + matchingRole ? matchingRole.user : undefined, + ); } }} placeholder={ @@ -591,10 +591,7 @@ export const AccessPolicyTable = ({ : "false" }`} onChange={(read: React.ChangeEvent) => - arrayHelpers.replace(formik.values.policies.findIndex(p => p === policy), { - ...policy, - read: read.target.checked, - }) + formik.setFieldValue(`policies.${index}.read`, read.target.checked) } /> @@ -618,11 +615,7 @@ export const AccessPolicyTable = ({ : "false" }`} onChange={(write: React.ChangeEvent) => - arrayHelpers.replace(formik.values.policies.findIndex(p => p === policy), { - ...policy, - write: - write.target.checked, - }) + formik.setFieldValue(`policies.${index}.write`, write.target.checked) } />