Skip to content

Commit d8c2683

Browse files
authored
Merge pull request #209 from DEFRA/fix/DF-513-empty-checkbox-condition
Fix/df 513 empty checkbox condition
2 parents 36cd8f8 + 6f3bc86 commit d8c2683

7 files changed

Lines changed: 5636 additions & 12 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
},
7171
"license": "SEE LICENSE IN LICENSE",
7272
"dependencies": {
73-
"@defra/forms-model": "^3.0.552",
73+
"@defra/forms-model": "^3.0.555",
7474
"@defra/hapi-tracing": "^1.26.0",
7575
"@elastic/ecs-pino-format": "^1.5.0",
7676
"@hapi/boom": "^10.0.1",

src/server/plugins/engine/models/FormModel.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,10 @@ export class FormModel {
363363
// Add page to context
364364
context.relevantPages.push(nextPage)
365365

366-
this.assignEvaluationState(context, nextPage)
366+
// Engine.V2 is excluded here as this will have already been done in initialiseContext()
367+
if (this.engine !== Engine.V2) {
368+
this.assignEvaluationState(context, nextPage)
369+
}
367370

368371
this.assignRelevantState(context, nextPage)
369372

@@ -389,14 +392,12 @@ export class FormModel {
389392
}
390393

391394
private initialiseContext(context: FormContext) {
392-
// For the V2 engine, we need to initialise `evaluationState` to null
393-
// for all keys. This is because the current condition evaluation
394-
// library (eval-expr) will throw if an expression uses a key that is undefined.
395+
// For the V2 engine, we initialise `evaluationState` for all keys.
396+
// This is because the current condition evaluation library (eval-expr)
397+
// will throw if an expression uses a key that is undefined.
395398
if (this.engine === Engine.V2) {
396399
for (const page of this.pages) {
397-
for (const key of page.keys) {
398-
context.evaluationState[key] = null
399-
}
400+
this.assignEvaluationState(context, page)
400401
}
401402
}
402403
}

0 commit comments

Comments
 (0)