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] Does not play nicely with TextField margin dense #33155

Closed
2 tasks done
dwjohnston opened this issue Jun 15, 2022 · 2 comments · Fixed by #36404
Closed
2 tasks done

[Stack] Does not play nicely with TextField margin dense #33155

dwjohnston opened this issue Jun 15, 2022 · 2 comments · Fixed by #36404
Labels
bug 🐛 Something doesn't work component: Stack The React component.

Comments

@dwjohnston
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When you have a row Stack with two TextFields margin dense, they are misaligned:

      <Stack spacing={2} direction="row">
        <TextField margin="dense" />
        <TextField margin="dense" />
      </Stack>

image

Expected behavior 🤔

The text fields should be aligned.

Steps to reproduce 🕹

Repro: https://codesandbox.io/s/basicstack-demo-material-ui-forked-khtbqp?file=/demo.tsx:566-696

Context 🔦

Horizonal forms - eg. a filter bar.

Your environment 🌎

See repro

@dwjohnston dwjohnston added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 15, 2022
@oliviertassinari oliviertassinari added the component: Stack The React component. label Jun 15, 2022
@oliviertassinari
Copy link
Member

oliviertassinari commented Jun 15, 2022

What we do here

is indeed strange. I guess we should either always reset the margin, or never do it. I wish we could use flex gap but we can't, it would not be coherent with https://mui.com/material-ui/getting-started/supported-platforms/#browser.

@mnajdova mnajdova self-assigned this Jun 20, 2022
@oliviertassinari oliviertassinari changed the title Stack does not play nicely with TextField margin dense [Stack] Does not play nicely with TextField margin dense Aug 21, 2022
@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 21, 2022
@leonbloy
Copy link

leonbloy commented Nov 4, 2022

To those working on this issue:

The spacing in Stack causes many problems.

It does not plays nicely with Divider (variant=middle) and also with margins of children ( it treats the first item differently)

Here's a sample

https://codesandbox.io/s/wandering-pine-mdluzs?file=/demo.tsx

In this example, all works ok without spacing. With spacing={2} , the Divider middle attribute is lost, and the children margins after the first one are messed up

image

const STYLE = {
  border: "1px solid grey",
  borderRadius: 1,
  "& svg": { m: 1.5 }
};

export default function VerticalDividerMiddle() {
  return (
    <div>
      <Stack sx={STYLE} direction="row">
        <FormatBoldIcon />
        <FormatAlignRightIcon />
        <FormatBoldIcon />
        <Divider orientation="vertical" variant="middle" flexItem />
        <FormatAlignRightIcon />
        <FormatBoldIcon />
      </Stack>
      <div>...</div>
      <Stack spacing={2} sx={STYLE} direction="row">
        <FormatBoldIcon />
        <FormatAlignRightIcon />
        <FormatBoldIcon />
        <Divider orientation="vertical" variant="middle" flexItem />
        <FormatAlignRightIcon />
        <FormatBoldIcon />
      </Stack>
    </div>
  );
}

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: Stack The React component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants