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:
parent
1a6a2c0ae9
commit
e6094a83a8
|
@ -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}
|
||||
|
|
Loading…
Reference in New Issue