[Feature] built-in debounce support on async select#3254
[Feature] built-in debounce support on async select#3254mmuller99 wants to merge 10 commits intoJedWatson:masterfrom
Conversation
|
@mmuller99 pretty cool, but this seems to introduce a new problem when mixing Async with Creatable: The "New entry" indicator flashes briefly before the search happens. GIF recording below: |
|
@dustinsoftware thanks for the feedback. I have a feeling its to do with "allowCreateWhileLoading", will have a look. |
|
It looks like the problem can be avoided by debouncing the constructor(props: Props) {
super();
this.loadOptions = props.debounceInterval
? debounce(this.handleLoadOptions, props.debounceInterval)
: this.handleLoadOptions;
}
handleLoadOptions = (inputValue: string, callback: (?Array<*>) => void) => {
// same method contents, but the method name is renamed to avoid confusion
};
handleInputChange = (newValue: string, actionMeta: InputActionMeta) => {
// other logic
this.setState(
{
inputValue,
isLoading: true,
passEmptyOptions: !this.state.loadedInputValue,
},
() => {
this.loadOptions(inputValue, options => {
if (!this.mounted) return;
if (options) {
this.optionsCache[inputValue] = options;
}
if (request !== this.lastRequest) return;
delete this.lastRequest;
this.setState({
isLoading: false,
loadedInputValue: inputValue,
loadedOptions: options || [],
passEmptyOptions: false,
});
});
},
);
}
render() {
return (
<SelectComponent
// other props
onInputChange={this.handleInputChange}
/>
);
} |
|
any chance on an update on this? glad to help if needed @mmuller99 |
4581fad to
fe6838d
Compare
|
@dustinsoftware thanks for the pointer, I debounced the loadOptions instead. It's been expressed by the owner that he wants the debounce implementation left to the user here. Maybe one of the collaborators can express their opinion on this PR? BTW, @gsinovsky thanks! |
|
Hi @JedWatson, any chance on reviewing and merging this? |
|
@gwyneplaine any feedback? |
|
@JedWatson @mmuller99 still very interested in seeing this merged and published. |
|
@mmuller99 definitely haven't forgotten about this PR, will be looking into this more deeply as part of our work to refactor async select. Will have a deeper look at this as soon as I have more time on my hands :) thanks for your patience |
|
Strong +1 to this feature request |
…to feature-debounceOnAsyncSelect
|
There's a plan to merge this feature soon? |
|
This is just what I need in my current project! |
|
It's nearly November 2019...is there an update yet? |
|
Please! Let it be one
Gustavo Siñovsky
Software Engineer
…On Mon, Oct 28, 2019, 22:27 bluefire2121 ***@***.***> wrote:
It's nearly November 2019...is there an update yet?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3254?email_source=notifications&email_token=ABNBREMUQ3ZHTPOFFACGOOLQQ6GQZA5CNFSM4GILI662YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECO5RKI#issuecomment-547215529>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABNBRENZQPLR2A7TUZHB5FTQQ6GQZANCNFSM4GILI66Q>
.
|
|
|
Any update on this PR? After using AsyncSelect, it is apparent that debounce must be a necessary accompaniment to AsyncSelect. |
|
Any updates? This is 100% a required feature for async select. |
|
It's a long awaited async feature for |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit df41e7f:
|
|
FWIW, this can be also done currently with a function that takes a promise and returns a debounced promise (but not with any ordinary debounce functions): https://gist.github.com/balazs-endresz/c0c814a513724f44d90265422b9ae530 Call this outside a component or with |
|
Any updates???????? Really needed :D |
|
Make a fork and build it yourself?
…On Tue, Oct 13, 2020 at 8:37 AM, Minh Kha ***@***.***> wrote:
Any updates???????? Really needed :D
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3254 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHGCFQ44GWBNL63OV3LIOTSKRX3XANCNFSM4GILI66Q>
.
|
|
EDIT: 🎉 I've archived the fork now that we've got some momentum in this repo and Jed is involved again. Sorry for the disturbance! |
this is not working at all, there is some other workaround? |
|
Greetings, @JedWatson has expressed the following opinion #473 (comment)
For those looking for a solution, please feel free to try the solution suggested here: #614 (comment) const loadOptions = React.useCallback(
debounce((inputValue, callback) => {
getOptions(inputValue).then(options => callback(options))
}, 500),
[]
);
return <AsyncSelect loadOptions={loadOptions} {...otherProps} />Demo: codesandbox |
|
Hey everyone, and thanks for the PR @mmuller99 Sorry for the lack of comms here, below is my response but I also want to acknowledge that this should have been said much earlier. My view on this is that it is something you can (reasonably) easily do outside of react-select when you need it, and many libraries exist already specifically to make debouncing function calls easy. As we've seen from the challenging history maintaining the library, even simple features add to the already huge surface area so the bar for inclusion of anything that can be done "in user-land" is really high. However talking through it with @ebonow and @Methuselah96 in our maintainers sync this week, the combination of these points have gotten it over the line:
We're in the middle of our TypeScript conversion now (#4489) so this PR won't go in directly, but we'll backlog adding this for a post-5.0 release |
|
Thank you @JedWatson , appreciate the honest response and that native |
i tried this but, the options won't be re-render when the data is ready |
|
With version 5 out, I think we are in a position to pick this up if someone is willing to put in the work to have this work converted to the new TypeScript rewrite. It seems reasonable that this is only applied to AsyncSelect and not Select correct? |
|
Hi, is there any update on this? |
|
The pull request as written doesn't have consensus, and I think for now the recommendation of debouncing the The feature isn't forgotten, but for now, I'm going to close this pull request. |


#3075
Proposal
loadOptionsis debounced by propdebounceInterval, minimizing unnecessary calls.Initial load unaffected.
Example:
loadOptionsonly called after 250 milliseconds