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.

Document how to use the b-dropdown scrollable and boundary option for html elements

See original GitHub issue

Is your feature request related to a problem? Please describe…

I’m using a b-dropdown inside a scrollable element and it doesn’t fit in the container. Per the documentation (https://bootstrap-vue.org/docs/components/dropdown#boundary-constraint) I need to set the boundary=“something”. Also, the dropdown is very large and needs to be scrollable.

I tried the boundary=“viewport” and “window” options and it just doesn’t constrain the dropdown or make it scrollable. I tried creating an absolutely-positioned div where the dropdown should appear, but I don’t think I’ve got the syntax right:

< b-dropdown boundary="#dropcontainer" > ...

<div id="dropcontainer"></div>

.drop-container {
  position: absolute;
  top: 100px;
  left: 100px;
  height: 100px;
  width: 200px;
}

All it does is position the dropdown as if it is a dropup.

Describe the solution you’d like

Just add an example to the docs of a scrollable dropdown in a scrollable div…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
tmorehousecommented, Mar 13, 2020

If you are wanting the content of the menu to scroll, you will need to apply some custom CSS

<template>
  <div>
    <b-dropdown class="my-class" text="Dropdown">
       <b-dropdown-item-button>Item 1</b-dropdown-item-button>
       <b-dropdown-item-button>Item 2</b-dropdown-item-button>
       <b-dropdown-item-button>Item 3</b-dropdown-item-button>
       <b-dropdown-item-button>Item 4</b-dropdown-item-button>
       <b-dropdown-item-button>Item 5</b-dropdown-item-button>
    </b-dropdown>
  </div>
</template>

<style>
  .my-class .dropdown-menu {
    max-height: 100px;
    overflow-y: auto;
  }
</style>

If using scoped styles:

<style scoped>
  .my-class /deep/ .dropdown-menu {
    max-height: 100px;
    overflow-y: auto;
  }
</style>
1reaction
andresuchitracommented, Jul 8, 2021

If you are wanting the content of the menu to scroll, you will need to apply some custom CSS

<template>
  <div>
    <b-dropdown class="my-class" text="Dropdown">
       <b-dropdown-item-button>Item 1</b-dropdown-item-button>
       <b-dropdown-item-button>Item 2</b-dropdown-item-button>
       <b-dropdown-item-button>Item 3</b-dropdown-item-button>
       <b-dropdown-item-button>Item 4</b-dropdown-item-button>
       <b-dropdown-item-button>Item 5</b-dropdown-item-button>
    </b-dropdown>
  </div>
</template>

<style>
  .my-class .dropdown-menu {
    max-height: 100px;
    overflow-y: auto;
  }
</style>

If using scoped styles:

<style scoped>
  .my-class /deep/ .dropdown-menu {
    max-height: 100px;
    overflow-y: auto;
  }
</style>

Alternatively you may also use:

::v-deep .dropdown-menu {
max-height: 200px;
overflow-y: auto;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dropdown | Components - BootstrapVue
Head to the Popper.js docs to see all the configuration options. Note: The props offset , boundary and no-flip may loose their effect...
Read more >
How to show a dropdown menu outside a parent element with ...
The only solution I found online and made sense to me, is to wrap the container to div with relative positioning and make...
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
The overscroll-behavior CSS property sets what a browser does when reaching the boundary of a scrolling area.
Read more >
Bootstrap Dropdowns - examples & tutorial
Responsive dropdown/caret built with Bootstrap 5. Examples of navbar dropdown, dropdown list, submenu, dropdown toggle, dropdown hover, hamburger icon ...
Read more >
Dropdowns - Bootstrap
Wrap the dropdown's toggle (your button or link) and the dropdown menu within .dropdown , or another element that declares position: relative; ....
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