From 05a7c62c9b06cda6df7ba369914d8167a9e40598 Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Thu, 5 Dec 2024 17:53:10 +0100 Subject: [PATCH] fix: account for expandable checklists in editor modal passport value validation (#4045) --- .../src/@planx/components/Checklist/Editor/Editor.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/editor.planx.uk/src/@planx/components/Checklist/Editor/Editor.tsx b/editor.planx.uk/src/@planx/components/Checklist/Editor/Editor.tsx index 49c592a064..2fcc03c3de 100644 --- a/editor.planx.uk/src/@planx/components/Checklist/Editor/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/Checklist/Editor/Editor.tsx @@ -72,8 +72,11 @@ export const ChecklistComponent: React.FC = (props) => { alert(JSON.stringify({ type, ...values, options }, null, 2)); } }, - validate: ({ options, ...values }) => { + validate: ({ options, groupedOptions, ...values }) => { const errors: FormikErrors = {}; + // Account for flat or expandable Checklist options + options = + options || groupedOptions?.map((group) => group.children)?.flat(); if (values.fn && !options?.some((option) => option.data.val)) { errors.fn = "At least one option must set a data value when the checklist has a data field";