polaris icon indicating copy to clipboard operation
polaris copied to clipboard

Alignment issues using Stack component

Open reflog opened this issue 8 years ago • 5 comments

Issue summary

image

Expected behavior

Items should align

Steps to reproduce the problem

Here's a demonstration: https://codesandbox.io/s/m7p2mz1qny

Specifications

  • Polaris version: 2.1.1
  • React version: 16.3
  • Browser: Chrome
  • Device: Desktop
  • Operating System: Win10

I've tried different combinations of alignment options, with no luck. Any suggestions?

Thanks!

reflog avatar Jun 07 '18 13:06 reflog

We also have experienced the same problem.

I think the problem is that the labels for the TextField components added a "margin" where your garbage button does not.

Our fix was just to wrap the button in a div with a margin-top of 29px. But I do agree that Polaris should come up with a property we can add onto the component to lower it / align it with the rest of the components in the FormLayout Group.

mattchidley avatar Jun 07 '18 13:06 mattchidley

thanks @mattchidley . that's what I've done in the meantime. I wonder if there's any "official" solution to this?

reflog avatar Jun 09 '18 13:06 reflog

Currently there isn’t an official solution, but I think we’ve run into this before ourselves. I knocked out a quick prototype: https://codesandbox.io/s/73yy6q90x6

It still breaks under some circumstances (long field labels) but I’m wondering if this is something along the right lines.

ry5n avatar Jul 04 '18 00:07 ry5n

This issue has been inactive for 180 days and labeled with Icebox. It will be closed in 7 days if there is no further activity.

ghost avatar Feb 10 '19 00:02 ghost

Cleaning up issues. I'm not sure this is actually a bug. The alignment is set to fill, which uses align-items: stretch, which stretches items to fills the container, but still respects min-width/max-width. I don't think the intention would be to stretch a button's height and distort it.

The text field is being treated as one item within the stack, including its label, so it would take some tweaking to align the button. Something like:

<Stack
  alignment="leading"
  distribution="fill"
  spacing="tight"
  wrap={false}
>
    <TextField label="Field 1" onChange={() => {}} />
    <TextField label="Field 2" onChange={() => {}} error="error" />
    <TextField label="Field 3" onChange={() => {}} />
    <div style={{margin: '2.4rem 0'}}>
        <Button icon="delete" destructive />
    </div>
</Stack>

solonaarmstrong-zz avatar Feb 12 '19 20:02 solonaarmstrong-zz