title: Downshift autocomplete onBlur resetting value with Formik
body: <p>I have a form with a field that needs to show suggestions via an api call. The user should be allowed to select one of those options or not and that value that they type in gets used to submit with the form, but this field is required. I am using Formik to handle the form, Yup for form validation to check if this field is required, downshift for the autocomplete, and Material-UI for the field.</p>
  
  <p>The issue comes in when a user decides not to use one of the suggested options and the onBlur triggers. The onBlur always resets the field and I believe this is Downshift causing this behavior but the solutions to this problem suggest controlling the state of Downshift and when I try that it doesn't work well with Formik and Yup and there are some issues that I can't really understand since these components control the inputValue of this field.</p>
  
  <p>Heres what I have so far:</p>
  
  <pre><code>const AddBuildingForm = props =&gt; {
      const [suggestions, setSuggestions] = useState([]);
      const { values,
          errors,
          touched,
          handleChange,
          handleBlur,
          handleSubmit, 
          modalLoading,
          setFieldValue,
          setFieldTouched,
          classes } = props;
  
      const loadOptions = (inputValue) =&gt; {  
          if(inputValue &amp;&amp; inputValue.length &gt;= 3 &amp;&amp; inputValue.trim() !== "")
          {
              console.log('send api request', inputValue)
              LocationsAPI.autoComplete(inputValue).then(response =&gt;  {
                  let options = response.data.map(erlTO =&gt; { 
                      return {
                          label: erlTO.address.normalizedAddress,
                          value: erlTO.address.normalizedAddress
                      }
                  });
                  setSuggestions(options);
              });
          }
          setFieldValue('address', inputValue); // update formik address value
      }
  
      const handleSelectChange = (selectedItem) =&gt; {
          setFieldValue('address', selectedItem.value); // update formik address value
      }
  
      const handleOnBlur = (e) =&gt; {
          e.preventDefault();
          setFieldValue('address', e.target.value);
          setFieldTouched('address', true, true);
      }
  
      const handleStateChange = changes =&gt; {
          if (changes.hasOwnProperty('selectedItem')) {
              setFieldValue('address', changes.selectedItem)
            } else if (changes.hasOwnProperty('inputValue')) {
              setFieldValue('address', changes.inputValue);
            }
      }
  
      return (
          &lt;form onSubmit={handleSubmit} autoComplete="off"&gt;
              {modalLoading &amp;&amp; &lt;LinearProgress/&gt;}
              &lt;TextField
                  id="name"
                  label="*Name"
                  margin="normal"
                  name="name"
                  type="name"
                  onChange={handleChange}
                  value={values.name}
                  onBlur={handleBlur}
                  disabled={modalLoading}
                  fullWidth={true}
                  error={touched.name &amp;&amp; Boolean(errors.name)}
                  helperText={touched.name ? errors.name : ""}/&gt; 
              &lt;br/&gt;
              &lt;Downshift  id="address-autocomplete"
                  onInputValueChange={loadOptions}
                  onChange={handleSelectChange}
                  itemToString={item =&gt; item ? item.value : '' }
                  onStateChange={handleStateChange}
                 &gt;
                  {({
                          getInputProps,
                          getItemProps,
                          getMenuProps,
                          highlightedIndex,
                          inputValue,
                          isOpen,
                      }) =&gt; (
                          &lt;div&gt;
                              &lt;TextField
                                  id="address"
                                  label="*Address"
                                  name="address"
                                  type="address"
                                  className={classes.autoCompleteOptions}
                                  {...getInputProps( {onBlur: handleOnBlur})}
                                  disabled={modalLoading}
                                  error={touched.address &amp;&amp; Boolean(errors.address)}
                                  helperText={touched.address ? errors.address : ""}/&gt;
                              &lt;div {...getMenuProps()}&gt;
                                  {isOpen ? (
                                      &lt;Paper className={classes.paper} square&gt;
                                          {suggestions.map((suggestion, index) =&gt;
                                              &lt;MenuItem {...getItemProps({item:suggestion, index, key:suggestion.label})} component="div"  &gt;
                                                  {suggestion.value}
                                              &lt;/MenuItem&gt;
                                          )}
                                      &lt;/Paper&gt;
                                  ) : null}
                              &lt;/div&gt;
                          &lt;/div&gt;
                  )}                
              &lt;/Downshift&gt;
  
              &lt;Grid container direction="column" justify="center" alignItems="center"&gt;
                  &lt;Button id="saveBtn"
                          type="submit" 
                          disabled={modalLoading} 
                          className = {classes.btn}
                          color="primary" 
                          variant="contained"&gt;Save&lt;/Button&gt;
              &lt;/Grid&gt;
          &lt;/form&gt;
      );
  }
  
  const AddBuildingModal = props =&gt; {
      const { modalLoading, classes, autoComplete, autoCompleteOptions } = props;
      return(
          &lt;Formik
              initialValues={{ 
                  name: '', 
                  address: '',
              }}
              validationSchema={validationSchema}
              onSubmit = {
                  (values) =&gt; {
                      values.parentId = props.companyId;
                      props.submitAddBuildingForm(values);
                  }
              }
              render={formikProps =&gt; &lt;AddBuildingForm 
                                          autoCompleteOptions={autoCompleteOptions}
                                          autoComplete={autoComplete} 
                                          classes={classes} 
                                          modalLoading={modalLoading}
                                          {...formikProps} /&gt;}
          /&gt;
      );
  }
  </code></pre>