From 7f870977c0cc67f983e5e038832a38a139d70a99 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 18 Sep 2023 11:45:24 -0400 Subject: [PATCH] default checkbox value to undefined if it is false --- .../rjsf/carbon_theme/CheckboxWidget/CheckboxWidget.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spiffworkflow-frontend/src/rjsf/carbon_theme/CheckboxWidget/CheckboxWidget.tsx b/spiffworkflow-frontend/src/rjsf/carbon_theme/CheckboxWidget/CheckboxWidget.tsx index 25fca604..12ad71ae 100644 --- a/spiffworkflow-frontend/src/rjsf/carbon_theme/CheckboxWidget/CheckboxWidget.tsx +++ b/spiffworkflow-frontend/src/rjsf/carbon_theme/CheckboxWidget/CheckboxWidget.tsx @@ -42,6 +42,13 @@ function CheckboxWidget(props: WidgetProps) { rawErrors ); + // if the default value is false then set the value to undefined + // so it will fail validation. in practice, there is no other + // way that this prop could have the value false. it has to be the default. + if (value === false) { + onChange(undefined); + } + // if the parent rjsf schema is not of type "object", then rjsf sends "root" through as the id. // this creates issues with the carbon checkbox where it will not accept any clicks to the checkbox // so add fuzz to the id to ensure it is unique.