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

Remove the initial margin from dropdown/popover in favor of Popper #32524

Merged
merged 3 commits into from Feb 3, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion js/src/dropdown.js
Expand Up @@ -72,7 +72,7 @@ const PLACEMENT_RIGHT = isRTL ? 'left-start' : 'right-start'
const PLACEMENT_LEFT = isRTL ? 'right-start' : 'left-start'

const Default = {
offset: [0, 0],
offset: [0, 2],
flip: true,
boundary: 'clippingParents',
reference: 'toggle',
Expand Down
1 change: 1 addition & 0 deletions js/src/popover.js
Expand Up @@ -25,6 +25,7 @@ const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g')
const Default = {
...Tooltip.Default,
placement: 'right',
offset: [0, 8],
trigger: 'click',
content: '',
template: '<div class="popover" role="tooltip">' +
Expand Down
27 changes: 20 additions & 7 deletions scss/_dropdown.scss
Expand Up @@ -22,7 +22,7 @@
display: none; // none by default, but block on "open" of the menu
min-width: $dropdown-min-width;
padding: $dropdown-padding-y $dropdown-padding-x;
margin: $dropdown-spacer 0 0; // override default ul
margin: 0; // Override default margin of ul
@include font-size($dropdown-font-size);
color: $dropdown-color;
text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
Expand Down Expand Up @@ -68,8 +68,11 @@
.dropdown-menu {
top: auto;
bottom: 100%;
margin-top: 0;
margin-bottom: $dropdown-spacer;

&.show:not([data-popper-placement]) {
margin-top: 0;
margin-bottom: $dropdown-spacer;
}
}

.dropdown-toggle {
Expand All @@ -82,8 +85,11 @@
top: 0;
right: auto;
left: 100%;
margin-top: 0;
margin-left: $dropdown-spacer;

&.show:not([data-popper-placement]) {
margin-top: 0;
margin-left: $dropdown-spacer;
}
}

.dropdown-toggle {
Expand All @@ -99,8 +105,11 @@
top: 0;
right: 100%;
left: auto;
margin-top: 0;
margin-right: $dropdown-spacer;

&.show:not([data-popper-placement]) {
margin-top: 0;
margin-right: $dropdown-spacer;
}
}

.dropdown-toggle {
Expand Down Expand Up @@ -174,6 +183,10 @@

.dropdown-menu.show {
display: block;

&:not([data-popper-placement]) {
margin-top: $dropdown-spacer;
}
}

// Dropdown section headers
Expand Down
12 changes: 0 additions & 12 deletions scss/_popover.scss
Expand Up @@ -35,9 +35,6 @@
}

.bs-popover-top {
// Overrule margin set by popper.js
margin-bottom: $popover-arrow-height !important; // stylelint-disable-line declaration-no-important

> .popover-arrow {
bottom: subtract(-$popover-arrow-height, $popover-border-width);

Expand All @@ -56,9 +53,6 @@
}

.bs-popover-end {
// Overrule margin set by popper.js
margin-left: $popover-arrow-height !important; // stylelint-disable-line declaration-no-important

> .popover-arrow {
left: subtract(-$popover-arrow-height, $popover-border-width);
width: $popover-arrow-height;
Expand All @@ -79,9 +73,6 @@
}

.bs-popover-bottom {
// Overrule margin set by popper.js
margin-top: $popover-arrow-height !important; // stylelint-disable-line declaration-no-important

> .popover-arrow {
top: subtract(-$popover-arrow-height, $popover-border-width);

Expand Down Expand Up @@ -112,9 +103,6 @@
}

.bs-popover-start {
// Overrule margin set by popper.js
margin-right: $popover-arrow-height !important; // stylelint-disable-line declaration-no-important

> .popover-arrow {
right: subtract(-$popover-arrow-height, $popover-border-width);
width: $popover-arrow-height;
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/5.0/components/dropdowns.md
Expand Up @@ -899,7 +899,7 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
<tr>
<td><code>offset</code></td>
<td>array | string | function</td>
<td><code>[0, 0]</code></td>
<td><code>[0, 2]</code></td>
<td>
<p>Offset of the dropdown relative to its target. You can pass a string in data attributes with comma separated values like: <code>data-bs-offset="10,20"</code></p>
<p>When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: <code>[<a href="https://popper.js.org/docs/v2/modifiers/offset/#skidding-1">skidding</a>, <a href="https://popper.js.org/docs/v2/modifiers/offset/#distance-1">distance</a>]</code>.</p>
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/5.0/components/popovers.md
Expand Up @@ -270,7 +270,7 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
<tr>
<td><code>offset</code></td>
<td>array | string | function</td>
<td><code>[0, 0]</code></td>
<td><code>[0, 8]</code></td>
<td>
<p>Offset of the popover relative to its target. You can pass a string in data attributes with comma separated values like: <code>data-bs-offset="10,20"</code></p>
<p>When a function is used to determine the offset, it is called with an object containing the popper placement, the reference, and popper rects as its first argument. The triggering element DOM node is passed as the second argument. The function must return an array with two numbers: <code>[<a href="https://popper.js.org/docs/v2/modifiers/offset/#skidding-1">skidding</a>, <a href="https://popper.js.org/docs/v2/modifiers/offset/#distance-1">distance</a>]</code>.</p>
Expand Down