From d130a42766bca88de53b5e4f4a71cceee85ed340 Mon Sep 17 00:00:00 2001 From: Sasha Dresden Date: Mon, 19 Aug 2024 13:13:28 -0400 Subject: [PATCH] If candidate state only has 1 district, select it, otherwise clear the candidate district on state change --- .../candidate-office-input/candidate-office-input.component.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/front-end/src/app/shared/components/inputs/candidate-office-input/candidate-office-input.component.ts b/front-end/src/app/shared/components/inputs/candidate-office-input/candidate-office-input.component.ts index 23afbade1e..800ad4ac02 100644 --- a/front-end/src/app/shared/components/inputs/candidate-office-input/candidate-office-input.component.ts +++ b/front-end/src/app/shared/components/inputs/candidate-office-input/candidate-office-input.component.ts @@ -90,6 +90,9 @@ export class CandidateOfficeInputComponent extends BaseInputComponent implements } else { this.candidateDistrictOptions = []; } + this.form + .get(this.districtFormControlName) + ?.setValue(this.candidateDistrictOptions.length === 1 ? this.candidateDistrictOptions[0].value : null); }); // Run election_code, office, and state valueChange logic when initializing form elements