05/15 Update: inspector issue view

This commit is contained in:
Nguyen Ngo
2026-05-15 16:02:24 -04:00
parent 7320e88dec
commit 1b90c23b3e
3 changed files with 79 additions and 22 deletions
@@ -125,9 +125,19 @@ struct StartInspectionView: View {
}
.pickerStyle(.navigationLink)
.onChange(of: selectedProjectId) {
// Reset downstream selections when contract changes
selectedFacilityId = nil
selectedAreaId = nil
// Reset downstream selections when the user changes contract.
// Do NOT reset if the current facilityId already belongs to
// the newly selected contract this covers the pre-fill path
// where applyPreFill() sets both projectId and facilityId and
// the onChange fires before facilityId is applied, wiping it.
let facilityBelongsToContract = facilities.contains {
$0.serverId == selectedFacilityId &&
$0.projectId == selectedProjectId
}
if !facilityBelongsToContract {
selectedFacilityId = nil
selectedAreaId = nil
}
}
}
}