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

[docs][material-ui] Fix slider in color customization playground twitches when sliding #43671

Merged
merged 5 commits into from
Sep 14, 2024

Conversation

Nashyn
Copy link
Contributor

@Nashyn Nashyn commented Sep 9, 2024

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

@mui-bot
Copy link

mui-bot commented Sep 9, 2024

Netlify deploy preview

https://deploy-preview-43671--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against dd0ae07

@zannager zannager added docs Improvements or additions to the documentation component: slider This is the name of the generic UI component, not the React module! labels Sep 9, 2024
Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a 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)?

@ZeeshanTamboli ZeeshanTamboli changed the title [docs][Customization]Slider twitch issue resolved [docs][material-ui] Slider twitch issue resolved Sep 11, 2024
@ZeeshanTamboli ZeeshanTamboli added package: material-ui Specific to @mui/material and removed component: slider This is the name of the generic UI component, not the React module! labels Sep 11, 2024
@Nashyn
Copy link
Contributor Author

Nashyn commented Sep 13, 2024

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.

Copy link
Member

@ZeeshanTamboli ZeeshanTamboli left a 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) => {

@ZeeshanTamboli ZeeshanTamboli added the bug 🐛 Something doesn't work label Sep 13, 2024
@ZeeshanTamboli ZeeshanTamboli changed the title [docs][material-ui] Slider twitch issue resolved [docs][material-ui] Fix slider in color customization playground twitches when sliding Sep 13, 2024
@Nashyn
Copy link
Contributor Author

Nashyn commented Sep 14, 2024

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.

@ZeeshanTamboli ZeeshanTamboli merged commit 4bb9b33 into mui:master Sep 14, 2024
22 checks passed
@ZeeshanTamboli
Copy link
Member

@Nashyn Thanks for the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work docs Improvements or additions to the documentation package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs][material-ui] Slider in color customization playground twitches when sliding
4 participants