do not convert null to a string when clearing out a typeahead field w/ burnettk (#373)

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
Kevin Burnett 2023-07-07 07:51:22 -07:00 committed by GitHub
parent 1a6a2c0ae9
commit e6094a83a8
1 changed files with 9 additions and 1 deletions

View File

@ -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}