-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Autocomplete] Show an integration example #7477
[Autocomplete] Show an integration example #7477
Conversation
@wieseljonas As been building his own integration at the same time: That's confirming my thought that it's the best path to follow |
I agree, if there are any HOC's etc we could provide to aid in integration for any boilerplate code I would like to make those available. If it is simply too specific/brittle etc I also understand, and we should not provide additional helpers due to the magnitude of issues that could arise. Also, if someone wants to take a shot at maintaining this individual component separately, we would be happy to link to them etc. |
renderInputComponent={renderInput} | ||
suggestions={this.state.suggestions} | ||
// suggestions={suggestions} | ||
// alwaysRenderSuggestions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
@rosskevin Yeah, I have been thinking about providing a |
@oliviertassinari that's great good find. I had used I'm haven't tested extensively with mobile but I'll get to it! |
@wieseljonas I think that |
@oliviertassinari seems to be working well. I've been using this with |
Hi, I remodeled the example provided using react-autocomplete so I can use it in different situation (even with async requests and allowing controlled/uncontrolled). Ok now lets look at An finally you can make async requests on the If you want to style the textField just pass to SuggestField any prop that TextField can handle. (Except classes, use inputClasses instead) |
@arracso Thanks for sharing, we could use your SelectField implementation as a starting point for our own. At least, that's providing a better understanding of the landscape of the solutions available :). |
Here is a gist of @oliviertassinari's integration sample genericized as much as possible. All the pluggable methods are defaulted but overridable. I'm not sure this is suitable to include here, but thought I would offer it to others. Resulting use is simply: const suggestions = [
{ label: 'Afghanistan' },
{ label: 'Aland Islands' }
}
function getSuggestions (value) {
return filterByLabel(value, suggestions)
}
const AutoCompleteBasic = () => (
<AutoComplete
getSuggestions={getSuggestions}
placeholder='Search a country (start with a)'
/>
) |
Just for the record, I've been integrating our own take on AutoComplete into our app code. I'm in full agreement with @oliviertassinari at this point. There are too many decisions to be made to have a generic AutoComplete in material-ui. I think any attempt at including one would be inadequate for many and too complicated for most, so it is best to leave as an integration sample. |
@rosskevin I totally agree. Have you ever considered publishing the contents of your gist as a module on npm? While I agree that use cases vary largely when it comes to AutoComplete, I still believe that there are probably many people for whom your solution would be just good enough and who would appreciate if it could easily be added as an npm dependency. (Side note: I once published the contents of a gist as an npm package, which then evolved for more than 6 years and has become quite popular… So even though I myself haven't used it in the last 5 years there were apparently plenty of people who appreciated it and other people who were willing to continue maintaining it.) |
I published above, and might publish again because it is getting more complete...but seems like too many decisions to be a general use package. |
Here is my complete work on my This one is enhanced by:
Here's my gist: If someone is feeling helpful, it would be fantastic if my work on the |
Closes #4783 and all the issues associated.
I think we would better off by not porting the component. Instead, documenting how to use external libraries like react-autosuggest or providing an adapter. That goes into the strategy of having the v1 less opinionated and closer to our core business. The 50+ opened issues shows that building such component is hard, let's increase the synergy but showing how to use styleless libraries to solve the it.
cc @callemall/material-ui