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] Add Autocomplete component and introduce example of async call #9

Closed
ajoslin103 opened this issue Jun 6, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@ajoslin103
Copy link

ajoslin103 commented Jun 6, 2021

I don't know if you can do this...

Please consider somehow integrating https://www.npmjs.com/package/react-places-autocomplete, or: https://www.npmjs.com/package/material-ui-autocomplete-google-places,

I struggled through many different versions before finding one I could get working. (and it does work quite well once you get it going) The one I got working is a bit of a mess, I know you could do much better !!

It would be really nice for my form to have an address component whose data was gathered automatically

Thanks for your time and attention !

@dohomi
Copy link
Owner

dohomi commented Jun 8, 2021

@ajoslin103 integrating Autocomplete is currently on low priority I will see if I find time for it. I currently don't need it myself and I am pretty backed up with work.

@ajoslin103
Copy link
Author

I understand!

There aren't enough cycles in the day !!

You are doing so much for me, if I can make it work I'll contribute it

@dohomi dohomi added the enhancement New feature or request label Jun 8, 2021
@dohomi dohomi changed the title I don't know if you can do this... [Feature Request] Add Autocomplete component and introduce example of async call Jun 8, 2021
@AntalyanGriffin
Copy link

Autocomplete would be incredibly useful; I couldn't use this otherwise great project for my form because of not supporting Autocomplete which I needed :/

@bryanltobing
Copy link

async autocomplete is all I needed but I still can't find the proper way to do this. :(

@dohomi
Copy link
Owner

dohomi commented Jun 28, 2022

This feature finally landed in version 3.9.0

Please visit https://react-hook-form-material-ui.vercel.app/?path=/story/autocomplete--basic to see some basic use cases.

@dohomi dohomi closed this as completed Jun 28, 2022
@dohomi
Copy link
Owner

dohomi commented Jun 28, 2022

@bryantobing12 a simple way to solve with with the current version (example with apollo-client hook).

export function AsyncAutocomplete({ name, label, multiple, variables }: TermsSelectorProps) {
  const { loading, data, error } = useQuery(DOCUMENT_QUERY)
  if (error) {
    return (
      <Alert severity={'error'}>{error?.message}</Alert>
    )
  }
  return (
    <AutocompleteElement name={name}
                         loading={loading}
                         multiple={multiple}
                         label={label}
                         options={data?.term?.map(term => ({
                           id: term.id,
                           label: term.en
                         })) ?? []} />
  )
}

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

No branches or pull requests

4 participants