Bootstrap 4: Why Popover Inside Scrollable Dropdown Doesn't Show

Bootstrap 4: Why popover inside scrollable dropdown doesn't show?

There are some issues with popper.js, and how it positions dropdowns, popovers and tooltips. The solution is to set the data-boundary option on the popovers to window...

Demo on Codeply

$(document).ready(function() {  $('[data-toggle="popover"]').popover({  });});
.dropdown-menu{ height: 150px; overflow: hidden; overflow-y: auto}
<!DOCTYPE html><html><head>  <title>Bootstrap Example</title>  <meta name="viewport" content="width=device-width, initial-scale=1">  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script></head><body><div class="container">  <h2>Dropdowns</h2>  <div class="dropdown">    <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">      Dropdown button    </button>    <div class="dropdown-menu">      <a class="dropdown-item" href="#" title="Header" data-boundary="window" data-toggle="popover" data-placement="right" data-trigger="hover"data-content="Some content">Link 1</a></a>      <a class="dropdown-item" href="#" title="Header" data-boundary="window" data-toggle="popover" data-placement="right" data-trigger="hover" data-content="Some content">Link 2</a>      <a class="dropdown-item" href="#">Link 3</a>      <a class="dropdown-item" href="#">Link 4</a>      <a class="dropdown-item" href="#">Link 5</a>      <a class="dropdown-item" href="#">Link 6</a>      <a class="dropdown-item" href="#">Link 7</a>      <a class="dropdown-item" href="#">Link 8</a>      <a class="dropdown-item" href="#">Link 9</a>    </div>  </div></div>

bootstrap 4.1.3 dropdown+proper+ scrollable-menu = blinking

$('.lockFont').popover({
boundary:'window',
});

Bootstrap 4 drop-down menu scrolling instead of dropping

Your navigation list items need to be wrapped in a div with the collapse navbar-collapse class.

Here's a working Bootstrap 4 navbar example:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<nav class="navbar navbar-expand-lg navbar-light bg-light"> <a class="navbar-brand" href="#">Navbar</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav mr-auto"> <li class="nav-item active"> <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a> </li> <li class="nav-item"> <a class="nav-link" href="#">Link</a> </li> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Dropdown </a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <div class="dropdown-divider"></div> <a class="dropdown-item" href="#">Something else here</a> </div> </li> <li class="nav-item"> <a class="nav-link disabled" href="#">Disabled</a> </li> </ul> <form class="form-inline my-2 my-lg-0"> <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search"> <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button> </form> </div></nav>

Bootstrap 4 Dropdown - Disable auto placement caused by popper.js

Bootstrap 4.1

There is a new "display" option that disables popper.js dropdown positioning. Use data-display="static" to prevent popper.js from dynamically changing the dropdown position...

Bootstrap 4.0

There are some issues with popper.js and positioning.

I've found the solution is to position-relative the .dropdown, and set it as the data-boundary="" option in the dropdown toggle:
https://www.codeply.com/go/zZJwAuwC5s

  <div class="dropdown position-relative" id="dd">
<button type="button" data-boundary="dd" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 1</a>
...
</div>
</div>

The boundary is set to the id of the dropdown. Read more about data-boundary.


Related questions:

Bootstrap 4: Why popover inside scrollable dropdown doesn't show?

Scrolling a dropdown in a modal in Bootstrap4

bootstrap popover not showing on top of all elements

I was able to solve the problem by setting data-container="body" on the html element

HTML example:

<a href="#" data-toggle="tooltip" data-container="body" title="first tooltip">
hover over me
</a>

JavaScript example:

$('your element').tooltip({ container: 'body' }) 

Discovered from this link: https://github.com/twitter/bootstrap/issues/5889

Bootstrap 4 dropdown menu within accordion

Answering for people who might come from Google with the same issue.

I got a reply on the Bootstrap Git from a contributor and it was pointed out to me that it wasn't the accordion causing this. It's the <div class="table-responsive"> wrapper and the overflow-x: auto. Making this visible corrects this but obviously breaks the responsive scroll on the table.

Currently there is no true fix in this situation, where you have a table within an accordion with dropdown menu's.



Related Topics



Leave a reply



Submit