-
-
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
[Button] Add loading support #7223
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
you can create a function that disables button and another enables. and wrap your ajax request function like 1 call the disable button and in the disable/enable functions you can further do whatever customisation you need using like adding loaders etc. |
@dsslimshaddy Nice solution. At the moment i have made a wrapper component that injects a span into the button which add the loader. Futher more it prevents the onClick method from being called :-) ! That might work for my need at the moment. Thanks for the suggestion :-) |
Hi, if no one else has taken it, I'd like to try and implement this feature. |
@vritant24 Hi, that sounds awesome :-) ! |
On which buttons would this feature be applied on? |
There is only one button on the v1-alpha branch. |
@vritant24 Did you take this task :-) ? Otherwise i might look a bit into how this could be solved :-) |
@thupi yes you can go ahead and look into it. I've had to move on to other work |
I think if the feature is implemented we could check if the |
here's something i wrapped https://www.webpackbin.com/bins/-Kr01wKU_hD4ILcj8IPJ |
This comment has been minimized.
This comment has been minimized.
You could do something yourself which seems to work pretty well <Button>
{!this.props.loading ?
<CircularProgress size={14} /> : // Size 14 works pretty well
<Typography>Click Me</Typography>}
</Button> If you like to style your own button or dont really want to have the inner |
This comment has been minimized.
This comment has been minimized.
Hey there, should I add @slavab89 's implementation to the documentation? |
@CamdenKo Sure, it would be great :) |
Be careful that using LinearProgress inside of Button produces invalid HTML as LinearProgress is implemented using a div. And divs can't be placed inside of buttons, it's not valid HTML. |
@jankalfus |
We have tried to solve this problem in the core in #17810 but it didn't go into the core. I think that it would be great to resume the effort. |
@oliviertassinari Hmm, doesn't seem like the component prop is available in either CircularProgress or LinearProgress: https://github.com/mui-org/material-ui/blob/6ced014170c18eefa5549f2a165881a73d94f943/packages/material-ui/src/CircularProgress/CircularProgress.js |
@jankalfus It sounds like we have found a compelling use case for adding such |
Does CircularProgress need to be a child of the button? The current docs examples overlay the progress indicator over the button. https://material-ui.com/components/progress/#interactive-integration #17810 used the progress indicator as a startIcon, but looking at the spec the current approach in the docs seems closer: https://material.io/components/progress-indicators/#circular-progress-indicators "[Circular progress indicators] can be applied directly to a surface, such as a button or card." See also: "Integrating with actions" for more details and a video. (The other thing I noticed is that what we renamed to static has replaced the more complex animation that is currently used for circular determinate.) |
I think that it has the potential to give the best implementation. Without this approach, an extra div needs to be placed around the button, which might break the current display mode, e.g. inline vs block. @mbrookes Thanks for the link to the specification, I believe it's what Vuetify implements, it looks great. Keeping the same shape of the button seems an important property (layout stability). |
The tricky part is not the if / else isloading. If you have an array of rows and those rows have the custom component button, say, |
Description
I have a hard time indicating that the website is making a server request and the user might wait and at the same time prevent the user from clicking login again. Some of our users repeatedly click login if the server responds slowly.
It cloud be an excellent feature if the button could expect at "loading" prop. When the button is passed loading={true} it should disable interaction and indicate it is loading.
I am currently using material-ui@next in a project which is planned to be put into production soon :-) Great progress :-)!
Images & references
Screenshots is taken from https://vuetifyjs.com/components/buttons (Loaders section).
The text was updated successfully, but these errors were encountered: