-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix loading spinner issue on variant change #656
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works fine, but maybe another approach would be to wrap the button label in a <span>
and replace the textContent
of only the label instead of the whole button?
I feel like toggleAddButton()
is making an incorrect assumption that the add-to-cart button can only contain text and no children, so perhaps this root cause should be addressed.
Good point @KaichenWang 🤔 I've changed the approach following your suggestion. Let me know what you think :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected! :dancing-razz:
The <span>
idea was really nice and didn't break the layout :D
Why are these changes introduced?
Fixes #636
What approach did you take?
I moved the spinner outside of the button and added it as the next sibling element of the atc. This way the element isn't removed on variant changed (it was before as we update the
textContent
of the atc button).Also added some product/feat. product specific styling to place the spinner relative to the button form.
Other considerations
Some options I considered:
product-form__buttons
element and position it absolutely, relative to the form. I will give this a try and report back. Edit: looks good this way.Demo links
Checklist