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

Fix .dropdown-item border-radius when $dropdown-padding-y is 0 #36447

Merged
merged 1 commit into from Jun 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions scss/_dropdown.scss
Expand Up @@ -66,6 +66,18 @@
left: 0;
margin-top: var(--#{$prefix}dropdown-spacer);
}

@if $dropdown-padding-y == 0 {
> .dropdown-item:first-child,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late to the party, but .dropdown-menu > li isn't right, there's usually an anchor (<a>) tag in between.
Shall we just skip the >?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdo I'm sure you get auto-tagged, but just in case you don't.

Copy link

@TomONeill TomONeill Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @mdo, my last comment didn't make sense I just realised. But I do have a scenario where the fix doesn't work:

  <ul class="dropdown-menu">
    <div style="max-height: 400px">
      <li><a class="dropdown-item" href="#">Menu item</a></li>
      <li><a class="dropdown-item" href="#">Menu item</a></li>
      <li><a class="dropdown-item" href="#">Menu item</a></li>
    </div>
  </ul>

If we'd get rid of the > selector, I think it will work in these cases too.

What do you think?

> li:first-child .dropdown-item {
@include border-top-radius(var(--#{$prefix}dropdown-inner-border-radius));
}
> .dropdown-item:last-child,
> li:last-child .dropdown-item {
@include border-bottom-radius(var(--#{$prefix}dropdown-inner-border-radius));
}

}
}

// scss-docs-start responsive-breakpoints
Expand Down Expand Up @@ -172,18 +184,6 @@
background-color: transparent; // For `<button>`s
border: 0; // For `<button>`s

// Prevent dropdown overflow if there's no padding
// See https://github.com/twbs/bootstrap/pull/27703
@if $dropdown-padding-y == 0 {
&:first-child {
@include border-top-radius(var(--#{$prefix}dropdown-inner-border-radius));
}

&:last-child {
@include border-bottom-radius(var(--#{$prefix}dropdown-inner-border-radius));
}
}

&:hover,
&:focus {
color: var(--#{$prefix}dropdown-link-hover-color);
Expand Down