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

[Stack] Doesn't reset margin on first item #37381

Closed
2 tasks done
rational-kunal opened this issue May 23, 2023 · 3 comments · Fixed by #37525
Closed
2 tasks done

[Stack] Doesn't reset margin on first item #37381

rational-kunal opened this issue May 23, 2023 · 3 comments · Fixed by #37525
Assignees
Labels
bug 🐛 Something doesn't work component: FormControl The React component component: Stack The React component.

Comments

@rational-kunal
Copy link

rational-kunal commented May 23, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Link to live example: https://codesandbox.io/s/sad-aj-45wiii?file=/src/App.js

Screenshot 2023-07-01 at 13 09 40
import Stack from "@mui/material/Stack";
import FormControlLabel from "@mui/material/FormControlLabel";
import Switch from "@mui/material/Switch";

export default function App() {
  return (
    <Stack direction="column" spacing={1}>
      <FormControlLabel
        value="Auto Seek"
        control={<Switch color="primary" />}
        label="Auto skip intro"
      />
      <FormControlLabel
        value="Auto Seek"
        control={<Switch color="primary" />}
        label="Auto skip intro"
      />
      <FormControlLabel
        value="Auto Seek"
        control={<Switch color="primary" />}
        label="Auto skip intro"
      />
    </Stack>
  );
}

Current behavior 😯

There is additional space in front of the first switch in the stack.

Expected behavior 🤔

All the switch elements should be perfectly aligned.

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
  System:
    OS: macOS 13.3.1
  Binaries:
    Node: 19.8.1 - /opt/homebrew/bin/node
    Yarn: Not Found
    npm: 9.5.1 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 113.0.5672.126
    Edge: Not Found
    Firefox: Not Found
    Safari: 16.4
  npmPackages:
    @emotion/react: ^11.11.0 => 11.11.0
    @emotion/styled: ^11.11.0 => 11.11.0
    @mui/base:  5.0.0-beta.2
    @mui/core-downloads-tracker:  5.13.2
    @mui/icons-material: ^5.11.16 => 5.11.16
    @mui/material: ^5.13.2 => 5.13.2
    @mui/private-theming:  5.13.1
    @mui/styled-engine:  5.13.2
    @mui/system:  5.13.2
    @mui/types:  7.2.4
    @mui/utils:  5.13.1
    @types/react: ^18.0.14 => 18.2.6
    react: ^18.2.0 => 18.2.0
    react-dom: ^18.2.0 => 18.2.0
@rational-kunal rational-kunal added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 23, 2023
@zannager zannager added component: Stack The React component. component: FormControl The React component labels May 24, 2023
@hbjORbj hbjORbj assigned hbjORbj and unassigned siriwatknp May 24, 2023
@hbjORbj hbjORbj added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 24, 2023
@hbjORbj
Copy link
Member

hbjORbj commented May 24, 2023

It indeed seems like a bug. I will investigate.

@hbjORbj hbjORbj changed the title Stack of FormControlLabel does not have correct layout [Stack] misalignment May 24, 2023
@gitstart
Copy link
Contributor

gitstart commented Jun 1, 2023

@hbjORbj @rational-kunal I would like to pick this up

@sai6855 sai6855 self-assigned this Jun 5, 2023
@oliviertassinari oliviertassinari changed the title [Stack] misalignment [Stack] Doesn't reset margin on first item Jul 1, 2023
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 1, 2023

@rational-kunal Note that you can use useFlexGap to workaround the problem: https://mui.com/system/react-stack/#flexbox-gap

Screenshot 2023-07-01 at 13 11 28

https://codesandbox.io/s/amazing-framework-fss8w6?file=/src/App.js

We will likely make this the default in the next major version (the only downside is no support for negative spacing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: FormControl The React component component: Stack The React component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants