Skip to content
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

[MdButton] Spinners and buttons don't play well together #1647

Open
BigBadaboom opened this issue Mar 29, 2018 · 8 comments
Open

[MdButton] Spinners and buttons don't play well together #1647

BigBadaboom opened this issue Mar 29, 2018 · 8 comments

Comments

@BigBadaboom
Copy link

In order to indicate a processing/busy state, I embed an <md-spinner> in a button while a backend API is being called.

<md-button v-if="isSubmitting">
    <md-progress-spinner md-mode="indeterminate"></md-progress-spinner>
</md-button>

<md-button v-else ... @click.native="submit">Submit</md-button>

However something weird happens when you click this button. Try clicking the button in the following fiddle: https://jsfiddle.net/x8gds6t6/13/

For about a second after the button switches back from the spinner to "Submit" the label is positioned in the wrong place on the button. In fact, if you click lots of times quickly, it can get even worse. The button gets wider than it is supposed to be..

In my real-world app, the effect is even worse than what happens in this fiddle. The button can get very wide indeed.

verify2
verify1

Looking at the DOM, the DIV.md-button-content seems to accumulate multiple copies of the spinner markup. They then slowly disappear one by one until the button returns to normal form. See below:

dom

The problem doesn't seem to happen if you use plain text instead of a spinner. See: https://jsfiddle.net/x8gds6t6/14/

@Samuell1
Copy link
Member

Samuell1 commented Mar 29, 2018

We doesnt support spinners inside button. It's against material design guidelines.

I recommed you to make overlay that will have your spinner on top of your form.
(You can check example of loading overlay here: https://codesandbox.io/s/github/vuematerial/examples/tree/master/examples/login)

@BigBadaboom
Copy link
Author

Where in the guidelines does it say that this is not allowed? I couldn't find anything that says that.

@BigBadaboom
Copy link
Author

I found a solution. The following CSS solves the problem for me.

BUTTON.md-button .md-progress-spinner.md-indeterminate.md-progress-spinner-enter,
BUTTON.md-button .md-progress-spinner.md-indeterminate.md-progress-spinner-leave-active
{
  display: none;
}

@Samuell1
Copy link
Member

@BigBadaboom Its not in guidelines because is againts material design. But there is one circular loading button but i think that will not match your style of form: https://material.io/guidelines/components/progress-activity.html

@BigBadaboom
Copy link
Author

I'm not sure I agree with that view. The guidelines don't explicitly disallow it. In fact it says:

[Buttons] may display text, imagery, or both.

https://material.io/guidelines/components/buttons.html#

I think a spinner counts as imagery.

Incidentally, the material-ui.com (React) team seem to support these:
mui/material-ui#7223

@VdustR
Copy link
Member

VdustR commented Mar 30, 2018

You can use this temporary

https://codepen.io/VdustR/pen/WzzRJG

@BigBadaboom
Copy link
Author

@VdustR Thanks for doing that. I appreciate it.

Getting rid of the spinner fade in and out, as I posted above, worked well enough for me.

@VdustR VdustR changed the title Spinners and buttons don't play well together [MdButton ]Spinners and buttons don't play well together Apr 2, 2018
@VdustR VdustR changed the title [MdButton ]Spinners and buttons don't play well together [MdButton] Spinners and buttons don't play well together Apr 2, 2018
@mbrookes
Copy link

We doesnt support spinners inside button. It's against material design guidelines.

That may have changed since:

"Circular progress indicators display progress by animating an indicator along an invisible circular track in a clockwise direction. They can be applied directly to a surface, such as a button or card."

https://material.io/components/progress-indicators/#circular-progress-indicators

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants