From 7f9a6bff6af73bf3b82f90e19255b4aa6552cceb Mon Sep 17 00:00:00 2001 From: 7PH Date: Wed, 5 Jul 2023 11:42:20 +0200 Subject: [PATCH] SONAR-19776 Fix github provisioning form cancellation --- .../authentication/hook/useConfiguration.ts | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/hook/useConfiguration.ts b/server/sonar-web/src/main/js/apps/settings/components/authentication/hook/useConfiguration.ts index e1d87ca0909..c3bf05a3b61 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/hook/useConfiguration.ts +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/hook/useConfiguration.ts @@ -87,25 +87,15 @@ export default function useConfiguration( const setNewValue = (key: string, newValue?: string | boolean | string[]) => { const value = values[key]; - if (value.multiValues) { - const newValues = { - ...values, - [key]: { - ...value, - newValue: newValue as string[], - }, - }; - setValues(newValues); - } else { - const newValues = { - ...values, - [key]: { - ...value, - newValue: newValue as string | boolean, - }, - }; - setValues(newValues); - } + setValues((values) => { + const newValues = { ...values }; + if (value.multiValues) { + newValues[key] = { ...value, newValue: newValue as string[] | undefined }; + } else { + newValues[key] = { ...value, newValue: newValue as string | boolean | undefined }; + } + return newValues; + }); }; const canBeSave = every( -- 2.39.5