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
0801cc0292
commit
218a0f1f0e
|
@ -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