Skip to content

Commit cc3519b

Browse files
committed
AP-5718 # Fixed nested forms with no value breaking conditional logic
1 parent 9fedbfa commit cc3519b

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111

1212
- `fileUploadService.restrictedFileTypes`
1313

14+
### Fixed
15+
16+
- nested forms with no value breaking conditional logic
17+
1418
## [8.8.1] - 2025-09-15
1519

1620
### Changed

src/conditionalLogicService/conditionallyShowOption.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ export type ShouldShowOption =
1212

1313
const handleAttributePredicate = (
1414
predicate: FormTypes.ChoiceElementOptionAttribute,
15-
model: SubmissionTypes.S3SubmissionData['submission'],
15+
model: SubmissionTypes.S3SubmissionData['submission'] | undefined,
1616
predicateElement: FormTypes.FormElementWithOptions,
1717
) => {
18-
const values = model[predicateElement.name]
18+
const values = model?.[predicateElement.name]
1919
if (!values) return true
2020

2121
if (
@@ -160,7 +160,7 @@ const isAttributeFilterValid = (
160160
}
161161

162162
// verify that at least one option is selected
163-
const values = formElementsCtrl.model[predicateElement.name]
163+
const values = formElementsCtrl.model?.[predicateElement.name]
164164
if (!values) return false
165165
// if the model value is an array, verify that it has a selection
166166
if (

src/conditionalLogicService/evaluateConditionalPredicate.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FormTypes, ConditionTypes } from '@oneblink/types'
1+
import { FormTypes, ConditionTypes, SubmissionTypes } from '@oneblink/types'
22
import { FormElementsCtrl } from './types'
33
import { typeCastService, formElementsService } from '..'
44
import evaluateConditionalOptionsPredicate from './evaluateConditionalOptionsPredicate'
@@ -27,7 +27,7 @@ function getElementAndValue(
2727
if (formElementWithName) {
2828
return {
2929
formElementWithName,
30-
value: formElementsCtrl.model[formElementWithName.name],
30+
value: formElementsCtrl.model?.[formElementWithName.name],
3131
}
3232
}
3333
} else if (formElementsCtrl.parentFormElementsCtrl) {
@@ -154,9 +154,10 @@ export default function evaluateConditionalPredicate({
154154
) {
155155
return
156156
}
157-
const formModel = formElementsCtrl.model[predicateElement.name] as {
158-
[name: string]: unknown
159-
}
157+
const formModel = formElementsCtrl.model?.[predicateElement.name] as
158+
| SubmissionTypes.S3SubmissionData['submission']
159+
| undefined
160+
160161
const result = conditionallyShowByPredicate(
161162
{
162163
model: formModel,

src/conditionalLogicService/generateFormElementsConditionallyShown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ const generateFormElementsConditionallyShownWithParent = ({
154154
if (formElementsConditionallyShown[element.name]) {
155155
break
156156
}
157-
const entries = formElementsCtrl.model[element.name] as
157+
const entries = formElementsCtrl.model?.[element.name] as
158158
| Array<SubmissionTypes.S3SubmissionData['submission']>
159159
| undefined
160160
formElementsConditionallyShown[element.name] = {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FormTypes, SubmissionTypes } from '@oneblink/types'
22

33
export type FormElementsCtrl = {
4-
model: SubmissionTypes.S3SubmissionData['submission']
4+
model: SubmissionTypes.S3SubmissionData['submission'] | undefined
55
flattenedElements: FormTypes.FormElement[]
66
parentFormElementsCtrl?: FormElementsCtrl
77
}

0 commit comments

Comments
 (0)