react-hook-form-mui icon indicating copy to clipboard operation
react-hook-form-mui copied to clipboard

[Feature Request] Allow Autocomplete component to perform async actions using current text input

Open DoWhileGeek opened this issue 1 year ago • 3 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Summary 💡

I would like to be able to, upon text entry, query my backend. I cant seem to hook into onInputChange without altering the way the lifecycle works. Once I add onInputChange, the input is no longer being rendered, I try to pass the useState value into it, but for the life of me I cannot get it to work. I imagine this may have to do with the RHF integration?

How would you suggest basically listening for text input changes without mucking up the lifecycle?

Examples 🌈

No response

DoWhileGeek avatar Aug 05 '24 01:08 DoWhileGeek

forgot to mention, looks highly related to #9, and the solution there is "load all the records", but I'd really like the user to be able to refine the records with a term sent to the backend.

DoWhileGeek avatar Aug 05 '24 01:08 DoWhileGeek

this seems to work for single, but breaks down when setting the multiple prop

            <AutocompleteElement
              label="parents"
              name="parents"
              options={relationOptions}
              value={term}
              autocompleteProps={{
                onInputChange: (event, value) => {
                  setTerm(value);
                },
              }}
            />

DoWhileGeek avatar Aug 05 '24 02:08 DoWhileGeek

@DoWhileGeek do you mind setting up a codepen for this? if things doesnt work with multiple prop, usually the default value isn't an empty array or value is not casted correctly. As this plugin only handles the react-hook-form part, I am sure setting the right autocompleteProps your requested feature might work out of the box.

dohomi avatar Aug 08 '24 00:08 dohomi