question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Popper warning regarding .dropdown-menu margin usage when data-bs-display="static"

See original GitHub issue

Prerequisites

Describe the issue

Popper 2.11.5 issues a warning in the browser console each time I open a dropdown which has data-bs-display="static"

Popper: CSS “margin” styles cannot be used to apply padding between the popper and its reference element or boundary. To replicate margin, use the offset modifier, as well as the padding option in the preventOverflow and flip modifiers.

It seems to be caused by the use of margin-top on .dropdown-menu, if I disable that rule in the browser inspector Popper doesn’t warn anymore:

.dropdown-menu {
  &[data-bs-popper] {
    margin-top: var(--#{$prefix}dropdown-spacer);
  }
}

Reduced test cases

Click button and watch browser console:

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

!!! Warning only appears when using non-minimized version of Popper, the minimized one removes console logging.

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, Popper.js 2.11.5

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:7
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
billhancecommented, Dec 13, 2022

I solved this by adding mt-0 to the dropdown-menu element.

1reaction
RandScullardcommented, Sep 9, 2022

We just upgraded from Bootstrap 5.1.3 to 5.2.1 and this Popper warning started appearing. We are using margin to offset a dropdown inside our Bootstrap navbar. Apparently we can’t use Popper’s suggested offset solution because dropdowns in a navbar don’t use Popper. It seems that at the moment, there is no solution for this warning in the context of a navbar dropdown.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Popper: CSS "margin" styles cannot be used to apply padding ...
I am working on a react project using react-bootstrap and facing this warning when clicking on the dropdown menu. Popper: CSS "margin" ...
Read more >
Dropdowns - Bootstrap
Put a form within a dropdown menu, or make it into a dropdown menu, and use margin or padding utilities to give it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found