diff --git a/src/webapp/pages/form-page/disease-outbreak-event/utils/applyRulesInFormState.ts b/src/webapp/pages/form-page/disease-outbreak-event/utils/applyRulesInFormState.ts index a430510e..b6bc90d1 100644 --- a/src/webapp/pages/form-page/disease-outbreak-event/utils/applyRulesInFormState.ts +++ b/src/webapp/pages/form-page/disease-outbreak-event/utils/applyRulesInFormState.ts @@ -23,8 +23,6 @@ export function applyRulesInFormState( toggleSectionVisibilityByFieldValue(section, updatedField.value, rule) ), }; - default: - return formState; } }, currentFormState); diff --git a/src/webapp/pages/form-page/disease-outbreak-event/utils/updateDiseaseOutbreakEventFormState.ts b/src/webapp/pages/form-page/disease-outbreak-event/utils/updateDiseaseOutbreakEventFormState.ts index 2b8cd650..caecd095 100644 --- a/src/webapp/pages/form-page/disease-outbreak-event/utils/updateDiseaseOutbreakEventFormState.ts +++ b/src/webapp/pages/form-page/disease-outbreak-event/utils/updateDiseaseOutbreakEventFormState.ts @@ -19,9 +19,16 @@ export function updateDiseaseOutbreakEventFormState( currentUserUsername: string ): FormState { const updatedForm = updateFormStateAndApplySideEffects(prevFormState, updatedField); - const updatedFormWithRulesApplied = diseaseOutbreakEventWithOptions.rules.length - ? applyRulesInFormState(updatedForm, updatedField, diseaseOutbreakEventWithOptions.rules) - : updatedForm; + + const updatedFormWithRulesApplied = + diseaseOutbreakEventWithOptions.rules.filter(rule => rule.fieldId === updatedField.id) + .length > 0 + ? applyRulesInFormState( + updatedForm, + updatedField, + diseaseOutbreakEventWithOptions.rules + ) + : updatedForm; const fieldValidationErrors = validateDiseaseOutbreakEventFormState( updatedFormWithRulesApplied,