-
-
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
[docs][material-ui] Fix slider in color customization playground twitches when sliding #43671
Conversation
Netlify deploy previewhttps://deploy-preview-43671--material-ui.netlify.app/ Bundle size report |
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.
Hey @Nashyn , thanks for the pull request. It's the same as #42119. Can you answer my question which I asked in #42119 (review)?
Hey @ZeeshanTamboli , the issue was caused due to the Typography component dynamically resizing within the flex container, which was causing shifts when displaying the shade value. By wrapping it in a div with a fixed width, I ensured that it had a consistent space for the text, preventing shifts in the layout and stabilizing the slider. This resolved the issue by maintaing consistent alignment. Thank you. |
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.
Hey @ZeeshanTamboli , the issue was caused due to the Typography component dynamically resizing within the flex container, which was causing shifts when displaying the shade value. By wrapping it in a div with a fixed width, I ensured that it had a consistent space for the text, preventing shifts in the layout and stabilizing the slider. This resolved the issue by maintaing consistent alignment. Thank you.
Thanks for pointing that out. How about we just set a minimum width to prevent it from shifting:
--- a/docs/data/material/customization/color/ColorTool.js
+++ b/docs/data/material/customization/color/ColorTool.js
@@ -237,7 +237,7 @@ function ColorTool() {
onChange={handleChangeShade(intent)}
aria-labelledby={`${intent}ShadeSliderLabel`}
/>
- <Typography>{shades[intentShade]}</Typography>
+ <Typography minWidth={40}>{shades[intentShade]}</Typography>
</Box>
<Box sx={{ width: 192 }}>
{hues.map((hue) => {
Hey @ZeeshanTamboli , Thanks for the suggestion. Setting a minWidth on the Typography component is an effective solution and simplifies the implementation. It directly addresses the layout stability without needing additional elements. I have committed the changes. Thank you. |
@Nashyn Thanks for the pull request. |
Hey, I have raised a PR that fixes a bug that I noticed in the color component in the docs where the slider twitches when between 400- 50 and henceforth I have a found a fix and updated it. Now the issue has been resolved.
Fixes #42019
MUI-Twitch.Issue.mp4
Before: https://mui.com/material-ui/customization/color/#playground
After: https://deploy-preview-43671--material-ui.netlify.app/material-ui/customization/color/#playground