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

List-group-item margin-top is offset when importing sass in a nested class #36662

Closed
3 tasks done
hadouin opened this issue Jul 3, 2022 · 1 comment · Fixed by #36663
Closed
3 tasks done

List-group-item margin-top is offset when importing sass in a nested class #36662

hadouin opened this issue Jul 3, 2022 · 1 comment · Fixed by #36663
Labels

Comments

@hadouin
Copy link
Contributor

hadouin commented Jul 3, 2022

Prerequisites

Describe the issue

Context

When using list-groups nested inside another class for exemple:

.darkmode
  @import 'bootstrap/scss/list-group';

The list-group-items do not behave correctly especially for borders (see code pen)

Cause

This is due to .list-group-item using a & + & selector. exemple:

.darkmode
  .list-group-item
    & + &
      border-top-width: 0px

compiles to:

.darkmode .list-group-item + .darkmode .list-group-item {
  border-top-width: 0px;
}

What we want

I propose we change the & in scss/_list-group-item.scss to .list-group-item

// ...
& + & { // The Issue would be here to change the second "&" to ".list-group-item"
  border-top-width: 0;

  &.active {
    margin-top: calc(var(--#{$prefix}list-group-border-width) * -1); // stylelint-disable-line function-disallowed-list
    border-top-width: var(--#{$prefix}list-group-border-width);
  }
}

compiled

.darkmode .list-group-item + .list-group-item {
  border-top-width: 0px;
}

Reduced test cases

https://codepen.io/Hadouin/pen/KKopyrW

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

Windows

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

Chrome

What version of Bootstrap are you using?

v5.2.0-beta1

@mdo
Copy link
Member

mdo commented Jul 25, 2022

Fwiw, there are other instances of ... + & { } in our codebase. Unsure if we feel the need to revisit all these selectors now, just some, or if we keep things as-is. Thoughts @julien-deramond?

@mdo mdo closed this as completed in #36663 Aug 3, 2022
mdo added a commit that referenced this issue Aug 3, 2022
…n a nested class (#36663)

* fix #36662 & + .list-group-item

* Ignore linter

Co-authored-by: Mark Otto <otto@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants