-
-
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] options are displayed even if loading is true #18559
Comments
@sclavijo93 This is related to #18450. What do you think of the opposite, we don't display the loading text in the popup if options are available? diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
index f236baa0e..bd6f52c52 100644
--- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
+++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
@@ -378,7 +378,9 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
open
>
<PaperComponent className={classes.paper}>
- {loading ? <div className={classes.loading}>{loadingText}</div> : null}
+ {loading && groupedOptions.length === 0 ? (
+ <div className={classes.loading}>{loadingText}</div>
+ ) : null}
{groupedOptions.length === 0 && !freeSolo && !loading ? (
<div className={classes.noOptions}>{noOptionsText}</div>
) : null} |
@oliviertassinari In my case I would like to show when the options are been loading. It's a way to say "Hey, the options that you're seeing aren't updated, just wait a minute please until the querying is finished". Or do you think that's not necessary? |
I think that in your case, I would use the CircularProgress demo we have, with the above changes. |
Hmm, didn't noticed that. Ok, I'll try with that solution. Thanks! Do you want me to send a PR with the code you mentioned above? |
If you have the time to send a pull request, that would be awesome :) |
Current Behavior 😯
When you have options available and you set
loading
to true, the options and the 'Loading..." message are visible at the same time.Expected Behavior 🤔
I think the options can be hidden while
loading
is set to true.Steps to Reproduce 🕹
Steps:
Context 🔦
I'm working on an autocomplete that calls an API on every keystroke using throttle as in the Google maps demo and I want to show the 'Loading...' message while the API is been queried.
I've found a workaround but maybe the options has to be hidden when loading by default?
Workaround:
Your Environment 🌎
The text was updated successfully, but these errors were encountered: