Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Clear input on Autocomplete

carolina123 free 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

  • ForumUser: 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