-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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] Remove label span #26666
[Button] Remove label span #26666
Conversation
transition: theme.transitions.create(['background-color', 'box-shadow', 'border-color'], { | ||
duration: theme.transitions.duration.short, | ||
}), |
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.
add transition (exclude color) due to this glitch.
loading-button-transition.mp4
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.
...(styleProps.loadingPosition === 'center' && { | ||
[`&.${buttonClasses.disabled}`]: { | ||
color: 'transparent', | ||
}, | ||
}), | ||
})); |
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.
@@ -88,6 +89,7 @@ const LoadingButtonLoadingIndicator = styled('div', { | |||
...(styleProps.loadingPosition === 'center' && { | |||
left: '50%', | |||
transform: 'translate(-50%)', | |||
color: theme.palette.action.disabled, |
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.
because of the above fix. color: transparent
makes indicator disappear, so need to force the color same is disabled state in Button
de5b0b9
to
48096de
Compare
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.
I could not spot any issues, we should just fix the test before merging
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.
Looks good, I could not test only Safari.
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.
Regarding the transition when centered, the only solution I could find is adding the span back for the loading label. So it can also support more complex children
I could find one change to improve the transition for the start and end icons that works both on this PR and HEAD:
diff --git a/packages/material-ui-lab/src/LoadingButton/LoadingButton.js b/packages/material-ui-lab/src/LoadingButton/LoadingButton.js
index 03195089be..c4cc467b73 100644
--- a/packages/material-ui-lab/src/LoadingButton/LoadingButton.js
+++ b/packages/material-ui-lab/src/LoadingButton/LoadingButton.js
@@ -56,11 +56,11 @@ const LoadingButtonRoot = styled(Button, {
transition: theme.transitions.create(['background-color', 'box-shadow', 'border-color'], {
duration: theme.transitions.duration.short,
}),
- [`& .${loadingButtonClasses.startIconLoadingStart}`]: {
- visibility: 'hidden',
- },
- [`& .${loadingButtonClasses.endIconLoadingEnd}`]: {
- visibility: 'hidden',
+ [`& .${loadingButtonClasses.startIconLoadingStart}, & .${loadingButtonClasses.endIconLoadingEnd}`]: {
+ transition: theme.transitions.create(['opacity'], {
+ duration: theme.transitions.duration.short,
+ }),
+ opacity: 0,
},
...(styleProps.loadingPosition === 'center' && {
[`&.${buttonClasses.disabled}`]: {
What it does on HEAD:
transition: theme.transitions.create(['background-color', 'box-shadow', 'border-color'], { | ||
duration: theme.transitions.duration.short, | ||
}), |
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.
In my opinion, adding the span back is a no go as we learned from other components that the structure should not surprise people. Screen.Recording.2564-06-10.at.09.49.28.movHere, I think it is better. remove |
There are two issues with the current animation: 1. the icons disappear instantly (which is quite visible), 2. the border-radius color isn't in sync with the text color. It doesn't feel as smooth as on #26666 (review). The last one can be fixed if we add a Another issue of not using a span: this do no longer work: <LoadingButton
onClick={handleClick}
loading={loading}
loadingIndicator="Loading..."
variant="outlined"
>
Notifications <Badge>9</Badge>
</LoadingButton>
Agree with this downside. It's definitely a tradeoff. |
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.
I have added a new commit. Happy to moving forward as is. At least, we are conscious about the <span>
tradeoff:
Cons:
- Surprising DOM structure for new users
Pros:
- Support any children. I think that we can expect new GitHub issues for it once this gets released. We will see if there is enough 👍 to force us to reconsider & revert.
- A slightly better transition
- Same DOM structure for previous users
@siriwatknp I have updated #20012 to check [ ] and link this PR. If you could do it for the other efforts, it will be 👌. |
BREAKING CHANGES
The
span
element that wraps children has been removed.label
classKey is also removed.Preview
https://deploy-preview-26666--material-ui.netlify.app/components/buttons/
Changes Summary
label
classes and element fromButton
andLoadingButton
LoadingButton
position: center styling because it rely on label before.History
button > span > children
exists as a workaround for flex container bug on button BUT not anymore, so this PR remove the span.https://github.com/philipwalton/flexbugs#flexbug-9