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

Floating labels and select positioned with different padding on Firefox #32636

Closed
ddneat opened this issue Dec 28, 2020 · 12 comments · Fixed by #34008
Closed

Floating labels and select positioned with different padding on Firefox #32636

ddneat opened this issue Dec 28, 2020 · 12 comments · Fixed by #34008

Comments

@ddneat
Copy link

ddneat commented Dec 28, 2020

While reading the documentation with the v5 examples, I noticed that the floating labels and select value are off. The following screenshot was taken from the documentation: https://getbootstrap.com/docs/5.0/forms/floating-labels/#selects

Bildschirmfoto 2020-12-28 um 13 07 45

  • macOS 11.0.1
  • Firefox 84.0.1

I could not reproduce this issue on Safari nor Chrome. My first investigation using the devtools and playing around with different paddings and font-sizes was unsuccessful.

Would you have any hints on resolving this issue? I would be happy to provide a PR.

@XhmikosR
Copy link
Member

padding left/right of .5rem fixes the issue for me on Firefox but then it breaks on Chromium.

Not sure if it's a browser issue, but it looks like it.

@linhub15
Copy link

linhub15 commented Jan 2, 2021

Material-UI also had this issue.
Looks like Firefox is rendering <select> differently than other browsers.

This is also present in the normal <select class="form-select">

image

Temporary Workaround

Add negative text-indent for Firefox.

@-moz-document url-prefix() {
  .form-select {
    text-indent: -.13rem;
  }
}

Example: https://codepen.io/linhub15/pen/RwGMogY

@ddneat
Copy link
Author

ddneat commented Jan 7, 2021

Thanks for your investigation and answers!

I would suggest to enhance the bootstrap reboot to resolve this issue? Probably the reboot should unify text-indent of all browsers by a fixed value.

What's your opinion? May I provide a PR?

@ddneat
Copy link
Author

ddneat commented Jan 7, 2021

It seems like Safari has a similar issue with line-height #32672

@mdo
Copy link
Member

mdo commented Jan 9, 2021

Edit: I'm a dummy and missed the fix was already enabled in the CodePen, sorry!

@mdo mdo added the browser-bug label Jan 9, 2021
@mdo
Copy link
Member

mdo commented Jan 9, 2021

Looks like this might be documented as a Firefox bug already: https://bugzilla.mozilla.org/show_bug.cgi?id=1582545. Unsure if we implement the hack, or go with mentioning the bug? Thoughts @twbs/css-review?

@ffoodd
Copy link
Member

ffoodd commented Jan 11, 2021

Isn't this related to a fix @MartijnCuppens had for our new file input? I recall talking about a -moz- proprty related to left padding…

I’d be in favor of implementing the hack, however I'd change padding instead of an arbitrary text-indent (to make it obvious) with a link to the related bug.

@mdo
Copy link
Member

mdo commented Jan 13, 2021

I don't think so @ffoodd? At least I don't see anything for that in our CSS—might be missing something. I thought the issue was with vertical alignment and sizing, not horizontal.

@XhmikosR
Copy link
Member

The issue is with horizontal alignment, and that Firefox has that extra padding compared to Chromium. IMHO we should add the hack if possible.

@ffoodd
Copy link
Member

ffoodd commented Jan 14, 2021

I confirm this is unrelated (found the comment tackling it ATT: #31955 (comment)).

However select > option have padding-inline-start: 3px which might cause this?

After a few tries, padding doesn't work, so I'd stick to text-indent as suggested. I'd go with 2px as a value, since it perfectly matches and I deduced this from comments in linked source file: they add 3px, taking a 2px border into account; we set a 1px border.

Turning this around, I didn't find a better way.

@alecpl
Copy link
Contributor

alecpl commented Jan 15, 2021

padding-inline-start: 0.5rem on the select fixes it for Firefox, but breaks for Chrome. But -moz-padding-start: 0.5rem does the trick. This would have to be applied to both .form-select as well as .form-floating > .form-select because both cases are broken.

@XhmikosR XhmikosR changed the title Floating labels and select positioned with different padding on Firefox for macOS Floating labels and select positioned with different padding on Firefox Jan 15, 2021
@alecpl
Copy link
Contributor

alecpl commented May 25, 2021

The PR is assigned to v5.0.2, but this ticket to v5.1.0, please correct this.

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

Successfully merging a pull request may close this issue.

6 participants