-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Use css to display Dropdown in Navbar #22782
Conversation
@@ -77,9 +77,8 @@ | |||
} | |||
|
|||
.dropdown-menu { | |||
position: static !important; | |||
position: static; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we scoped this to a max-width
media query instead? Would that mean we don't need to reset the styles later for .dropdown-menu
and .dropdown-menu-right
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.dropdown-menu-right
only exist here, because we handle that on our JS for the other Dropdown which aren't in a navbar.
But yes I think it's possible to add a media query just for the Dropdown position
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on branch .v4-dropdown-navbar
and made two pens:
The problem is that with our last commit:
.navbar-expand {
@each $breakpoint in map-keys($grid-breakpoints) {
$next: breakpoint-next($breakpoint, $grid-breakpoints);
$infix: breakpoint-infix($next, $grid-breakpoints);
&#{$infix} {
@include media-breakpoint-down($breakpoint) {
.dropdown-menu {
position: static;
float: none;
}
...
the rules position: static; float: none;
won't apply in case of:
- navbars that always collapse
.navbar
- navbars that never collapse,
.navbar-expand
This two use cases (navbar that always/never collapse) are already documented here.
I mentioned this, first time, here. I hope now It's much more clear :)
0dccebb
to
e836f59
Compare
|
e836f59
to
4e856a0
Compare
js/src/dropdown.js
Outdated
return placement | ||
|
||
if (this._inNavbar) { | ||
popperConfig.modifiers.AfterApplyStyle = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to make Popper apply styles and then remove them?
You could set the enabled
property of the applyStyle
modifier to !this._inNavbar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh thank you @FezVrasta ! Nice review !
Edit :
Finally I tried what you suggested but it add inline style see floating-ui/floating-ui#309
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna fix this tomorrow morning!
4e856a0
to
c62c1cf
Compare
In this PR, we remove CSS aplied by Popper.js (only for Dropdown in navbar) to let our CSS do the job.
We detect a weird behavior, If we have a navbar in 100% width container an horizontal scroll appear.
See this CodePen : https://codepen.io/zalog/pen/Rgrbod (first Navbar)
I'm not sure if it's really a bad behavior, maybe @mdo can help us in this use case ?
Thank you to @zalog to review/improve my first commit 👍
Close : #22699