Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
DoWhileGeek opened this issue Aug 5, 2024 · 3 comments

Comments

@DoWhileGeek
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • 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
Copy link
Author

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
Copy link
Author

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);
                },
              }}
            />

@dohomi
Copy link
Owner

dohomi commented Aug 8, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants