Clear input on Autocomplete


Topic: Clear input on Autocomplete

carolina123 asked 5 years ago

Expected behavior Autocomplete component could be cleared (from a method)

Actual behavior Autocomplete component can not be cleared (could only be cleared with the x on the input)

Resources (screenshots, code snippets etc.) Hello! Im using the Autocomplete in one of my components.. Im using it like this

 <MDBAutocomplete
         data={availableValues}
          label="new"
          clear
          id={`value-${member}`}
          required
         getValue={this.updateValue}
   />

And When I submit the form that has this Autocomplete input and some other inputs, I want to clear all the values from that inputs calling this method onSubmit..

addNewValue = newValue => {
    // call api with new value
    onAdd(newValue );
   // clear all inputs.. state? refs?
}

I tried using refs, or passing a value from the state and updating that value but with no luck. The only way in wich the Autocomplete input is being cleared is when clicking on the x inside the input. I didnt find more info about this on the documentation..

Do you know a way to achieve what I need?

Thanks in advance!!


Piotr Glejzer staff answered 5 years ago

Dear carolina123,

Autocomplete is a premium component, and according to our system, you use MDB Free version.

Please, provide us a number o your order or registered email to confirm your access to MDB Pro components and premium support. If you are a Pro user we will add you a badge to your profile.

Send it to me on email: p.glejzer@mdbootstrap.com or in the private message.

Best,
Piotr


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.8.6
  • Device: Computer
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No