From 250c85c35da4b712fcef635da9e9e2a8a9b830c5 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Wed, 3 Apr 2024 12:24:36 +0200 Subject: [PATCH] [#4099] Fix crash when using legacy Objects API registration Backport-of: #4104 --- .../registrations/userDefinedVariableEditHandlers.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openforms/js/components/admin/form_design/registrations/userDefinedVariableEditHandlers.js b/src/openforms/js/components/admin/form_design/registrations/userDefinedVariableEditHandlers.js index 6257d85e69..7aa46fc4c7 100644 --- a/src/openforms/js/components/admin/form_design/registrations/userDefinedVariableEditHandlers.js +++ b/src/openforms/js/components/admin/form_design/registrations/userDefinedVariableEditHandlers.js @@ -13,6 +13,7 @@ const onObjectsAPIUserDefinedVariableEdit = ( variable, originalVariable ) => { + if (registrationBackendOptions.version !== 2) return; // If the data type has changed, the mapped target might not be compatible anymore: const shouldRemove = originalVariable == null || variable.dataType !== originalVariable.dataType; @@ -23,15 +24,17 @@ const onObjectsAPIUserDefinedVariableEdit = ( if (matchingMappingIndex === -1) return; registrationBackendOptions.variablesMapping.splice(matchingMappingIndex, 1); + return registrationBackendOptions; } else { const keyChanged = variable.key !== originalVariable.key; - if (!keyChanged) return null; + if (!keyChanged) return; for (const mapping of registrationBackendOptions.variablesMapping) { if (mapping.variableKey === originalVariable.key) { mapping.variableKey = variable.key; } } + return registrationBackendOptions; } };