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

btn-group draws first input margin outside due to negative margin #36794

Closed
3 tasks done
2-5 opened this issue Jul 20, 2022 · 1 comment · Fixed by #37080
Closed
3 tasks done

btn-group draws first input margin outside due to negative margin #36794

2-5 opened this issue Jul 20, 2022 · 1 comment · Fixed by #37080

Comments

@2-5
Copy link

2-5 commented Jul 20, 2022

Prerequisites

Describe the issue

The left border of the first input in a btn-group is drawn outside parent, potentially being clipped if parent is using overflow-hidden or similar things which hard clip.

The problem appears if input is used before label, as in the Bootstrap documentation. If order is reversed, the output is fine (but there are other issues).

It seems this is the root source, for some reason .btn:not(:first-child) doesn't work as expected, it seems it applies to all children without filtering based on .btn class.

.btn-group {
  // Prevent double borders when buttons are next to each other
  > .btn:not(:first-child),
  > .btn-group:not(:first-child) {
    margin-left: -$btn-border-width;
  }
}

Real world regression:

Bootstrap 4.6:

2022-07-20_233126

Bootstrap 5.2:

2022-07-20_233141

Reduced test cases

https://codepen.io/costka/pen/BarRZda

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Chrome, Firefox

What version of Bootstrap are you using?

v5.2.0

@2-5
Copy link
Author

2-5 commented Jul 20, 2022

FWIW using :nth-child(2) instead of :first-child fixes the problem for me, not sure if it has other side-effects:

.btn-group {
  > .btn:not(:nth-child(2)),
  > .btn-group:not(:nth-child(2)) {
    margin-left: -$btn-border-width;
  }
}

@mdo mdo added this to v5.2.1 Sep 3, 2022
@mdo mdo moved this to Todo in v5.2.1 Sep 3, 2022
@mdo mdo added the confirmed label Sep 3, 2022
@mdo mdo closed this as completed in #37080 Sep 5, 2022
Repository owner moved this from Todo to Done in v5.2.1 Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants