-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Make Stateless and Composable #5062
Comments
@oliviertassinari glad to here it! Related #2294 :
So to split A. Make <AutoComplete
onBlur={...}
onFocus={...}>
<TextField
onBlur={...}
onFocus={...}
/>
<Popup
onBlur={...}
onFocus={...}
/>
</AutoComplete> B. Add props for <AutoComplete
onBlur={...}
onFocus={...}
onInputBlur={...}
onInputFocus={...}
onPopupBlur={...}
onPopupFocus={...}
/> In both cases we will need to store So |
@umidbekkarimov Your points sounds correct. I would definitely go with option A. over B. I have done quite some refactorization in this |
@oliviertassinari That sounds great! I forgot that I had related issue from long ago #4270 |
#2340 related issue, e.g: <AutoComplete>
<TextField {...textFieldProps}/>
<Popup {...popupProps}/>
{isLoading && (<LinearProgress mode="indeterminate" />)}
</AutoComplete> |
Hi @umidbekkarimov, is there a chance you could share your wrapper for those of us who want this sort of functionality before the next official release? |
@danielevora Actually it's not hard to implement, here the gist. But I didn't test it. (Version in my project with lot of dependencies - like immutable, rxjs, recompose, so i couldn't just copy-paste from it) |
@umidbekkarimov Sorry, to hijack this thread. |
@oliviertassinari np at all 👍 here working example I use rxjs here to control focus on element, mapping data and as replacement to sCU lifecycle |
Just and idea: Create package (e.g. |
Closed by #4783 |
react-autosuggest is stateless and composable. |
Is this solution already available? |
@jurandircastro Yes, on the v1-beta branch. |
Current api has props:
searchKey
- Text being input to auto complete.onUpdateInput
- Callback function that is fired when the user updates theTextField
.onNewRequest
- Callback function that is fired when a list item is selected, or enter is pressed in theTextField
.What if we change it with more common api:
value
- Current valueonChange
- Callback function that is fired when value is changedoptions
- Available valuesBut it's not enough, what if we want to use complex objects in options?
formatOption
- This function is called to format optionLooks more clear, but what if we want to format option differently in input?
formatInput
- This function is called to format input of current value (formatOption
will be used if this function is not provided)Now, what to do when user starts typing input?
parseInput
- This function is called to parse input text to valueSo, let's combine it all together.
1st example:
GeoAutocomplete
And if you want to validate just use like:
2nd example:
UserAutocomplete
And if you want to validate just use like:
PS Currently I use wrapper for
AutoComplete
that makes it work exactly like that - so I wanted to share these examples to optimise current behaviourPPS Related to #2957 and #2784
The text was updated successfully, but these errors were encountered: