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

Select DownArrow margin can't be overridden when to compensate for margin bottom of container #842

Closed
timReynolds opened this issue Apr 12, 2020 · 4 comments

Comments

@timReynolds
Copy link
Contributor

Describe the bug
Currently the select down arrow SVG is centered to the outer box rather than the inner select box. This means if you try to apply margin to the bottom outer box the arrow is incorrectly centered.

Screenshot 2020-04-12 at 20 41 30

This isn't a problem if equal padding is applied to the top and bottom however this normally isn't the case as you want to group the label with the select by having more padding at the bottom than the top where the label is positioned.

A work around is to apply padding to the top of the next label however this isn't ideal especially if the select is the last item in the form.

To Reproduce
Create a form with a label followed by a select using the following in the theme;

  forms: {
    label: {
      fontSize: 1,
      fontWeight: "bold",
      mb: 1,
    },
    input: {
      borderColor: "gray",
      borderRadius: 0,
      mb: 3,
      "&:focus": {
        borderColor: "primary",
        boxShadow: t => `0 0 0 2px ${t.colors.primary}`,
        outline: "none",
      },
    },
    select: {
      borderColor: "gray",
      mb: 3,
      "&:focus": {
        borderColor: "primary",
        boxShadow: t => `0 0 0 2px ${t.colors.primary}`,
        outline: "none",
      },
    },
    textarea: {
      borderColor: "gray",
      mb: 3,
      "&:focus": {
        borderColor: "primary",
        boxShadow: t => `0 0 0 2px ${t.colors.primary}`,
        outline: "none",
      },
    },

Expected behavior
There is either a way to offset the dropdown arrow margin or it's centered different to avoid this problem.

@lachlanjc
Copy link
Member

This is likely a bug that should be fixed, but in the meantime, can you use a nested svg selector inside your select variant to manually adjust its positioning?

@timReynolds
Copy link
Contributor Author

This is a good point I didn’t try targeting the SVG. Will do so today and report back

@timReynolds
Copy link
Contributor Author

As @lachlanjc pointed out you can use a nested selector to fix this like so;

    select: {
      ...sharedInputStyles,
      "& + svg": {
        "margin-top": "-16px",
      },
    },

@lachlanjc
Copy link
Member

Awesome. I think we can close this then? #706 seems to cover the same thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants