From 218a0f1f0e356dfb7342ff67d6fbcd767d1de839 Mon Sep 17 00:00:00 2001 From: Kevin Burnett <18027+burnettk@users.noreply.github.com> Date: Fri, 7 Jul 2023 07:51:22 -0700 Subject: [PATCH] do not convert null to a string when clearing out a typeahead field w/ burnettk (#373) Co-authored-by: jasquat --- .../custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spiffworkflow-frontend/src/rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx b/spiffworkflow-frontend/src/rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx index 7ee9e073b..9931ddf1d 100644 --- a/spiffworkflow-frontend/src/rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx +++ b/spiffworkflow-frontend/src/rjsf/custom_widgets/TypeaheadWidget/TypeaheadWidget.tsx @@ -114,7 +114,15 @@ export default function TypeaheadWidget({ onInputChange={typeaheadSearch} onChange={(event: any) => { setSelectedItem(event.selectedItem); - onChange(JSON.stringify(event.selectedItem)); + let valueToUse = event.selectedItem; + + // if the value is not truthy then do not stringify it + // otherwise things like null becomes "null" + if (valueToUse) { + valueToUse = JSON.stringify(valueToUse); + } + + onChange(valueToUse); }} id={id} items={items}