-
-
Notifications
You must be signed in to change notification settings - Fork 78.9k
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
Big dropdowns are unusable when used inside an overflow:scroll
container, due to being constrained inside it
#24251
Comments
Try this:
I use this for table responsive. |
@danijelGombac works in the jsFiddle, thanks 👍👍👍! I'm using Bootstrap from Vue.js with bootstrap-vue though, so I guess I have a bit of fiddling to do, but it looks doable. Still looks like desirable-by default behavior to me, so leaving the issue open. |
Curious if this is doable with Popper @Johann-S? Previously we have been constrained by the manual placement of dropdowns in the DOM. |
Yep we can add a |
@Johann-S @mdo thanks for the fast feedback 🙂! A proper fix in vanilla Bootstrap would be awesome, because even though the re-parenting trick works for vanilla Bootstrap, turns out my "I guess it's doable in bootstrap-vue with a bit of fiddling" comment at #24251 (comment) was wrong: re-parenting is a no-no for downstream reactive bindings like bootstrap-vue. Quoting @tmorehouse at bootstrap-vue/bootstrap-vue#1163 (comment) ,
@tmorehouse anything to comment on that |
@ronjouch regarding b-popover/b-tooltips, dynamically creatd new DOM elements are appended to the DOM (body by default, or the optional container) when the tip/popover opens. b-dropdown is different in that reactive content (i.e. the dropdown items which most likely have event listeners) are created by components outside of the dropdown component scope (even through they are children) We could try a re-parenting option, but it would require a new "dumb" wrapper element around the |
An usually unknown behavior of DOM and CSS is that an
The only situation when an
This behavior can be leveraged to make a popper overflow its scrolling parent.
In our specific case, the
|
@FezVrasta this appears to be a bit buggy in Firefox, and doesn't handle when the dropdown is wider than the container. It is still partially off screen. |
@tmorehouse the problem with col-2 is because Popper.js is not yet optimized for this use case. About Firefox, it looks like it's only the If this approach is something that Bootstrap wants to adopt I can work on Popper.js to make it work better to fit this need. |
@FezVrasta, @Johann-S @mdo @ronjouch For Bootstrap-Vue we have just added an option (via PR bootstrap-vue/bootstrap-vue#1440) to change the Popper.js reference: https://popper.js.org/popper-documentation.html#modifiers..preventOverflow This appears to work well from our tests so far, while still preserving the default behavior when scrollParent is set as the Before (with Now (with the Which renders the following if <div class="dropdown" style="position: static">
<button class="dropdown-toggle">Dropdown</button>
<div class="dropdown-menu">
<!-- dropdown items here -->
</div>
</div> |
seems nice @tmorehouse I'll give it a look 👍 |
@Johann-S We have also done something similar for popover/tooltip (without the use of Basically we have added a |
Overflow scroll elements doesn't play well with overflowing children with position anything but static: twbs/bootstrap#24251 Fix by padding with spacer div since user switcher has a known maximum height.
Overflow scroll elements doesn't play well with overflowing children with position anything but static: twbs/bootstrap#24251 Fix by padding with spacer div since user switcher has a known maximum height.
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337 closes #37594 Signed-off-by: Lucas Perais (lpe) <[email protected]>
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337 X-original-commit: c3273b7
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337 X-original-commit: c3273b7
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337 X-original-commit: c3273b7
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337 closes #38069 X-original-commit: c3273b7 Signed-off-by: Lucas Perais (lpe) <[email protected]>
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337 closes #38057 X-original-commit: c3273b7 Signed-off-by: Lucas Perais (lpe) <[email protected]>
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337 closes #38080 X-original-commit: c3273b7 Signed-off-by: Lucas Perais (lpe) <[email protected]>
Open a search view modal ("search more" on a m2o) Select a filter that will make records fall to zero The modal will shrink Trigger the opening of a dropdown (Filters), and make sure that there are many many menu items there (many filters) Before this commit, the dropdown was bigger than the modal which had a scroll bar, however, the dropdown itself was not scrollable properly So, clicking in it to select a menu item will fail when scrolled all the way down, because elements did not actually followed the scroll After this commit, the dropdown follows the scroll, and it is possible to use it even way down We use a behavior of bootstrap 4 itself: FIX: twbs/bootstrap#24976 ISSUE: twbs/bootstrap#24251 OPW 2076337 closes #38069 X-original-commit: c3273b7 Signed-off-by: Lucas Perais (lpe) <[email protected]>
All of this and apparently no official response? Still an issue in 2022. |
@SoftCircuits Commenting on a four year old issue without looking through the referenced issues and PRs isn't helpful. We did ship an official response by adding boundary options in the plugins. See #24976. If you're still having an issue, I highly suggest opening a new issue with a live demo to see if there's something else we can do. |
@SoftCircuits if you add data-boundary="viewport" to bootstrap menu element and position-static to parent container with .dropdown class, the problem goes away. Positioning is still not ideal but it works. |
Problem
When using a Bootstrap (4.0.0beta) Dropdown in an element that is a child of an
overflow:scroll
element, the dropdown is "stuck" inside the container, making it unusable if the dropdown contents are too big horizontally/vertically:Contrarily, a vanilla HTML
<select>
will merrily bleed out of theoverflow:scroll
element as necessary:See demo at JSFiddle/ronj/t6z6Lnfb.
Use case
A few words on the use case justifying this combination, as shown in the JSFiddle which mimics a webapp I'm working on:
overflow-y:scroll
div. Each filter has a dropdown which lets users modify filter options.→ As a user,
overflow-y:scroll
sidebar scrolling behavior (because the list of filters is of undetermined and potentially large height, depending on the number of filters)And as shown in the demo/screenshots, vanilla HTML
<select>
don't suffer from this problem, but it's not always practical/possible to revert back to using them, e.g. due to using features specific to Bootstrap Dropdown, or for consistent styling.Details
Bootstrap version: 4.0.0-beta
OS/Browser: Ubuntu 16.04.3 / {Chrome 63, Firefox 58}
This issue is a follow-up to SO / Letting a bootstrap
b-dropdown
escape out of anoverflow:scroll
container, but noticing regular<select>
are not affected, it starts to look like a bug, thus this issue. Sorry for the noise if I'm missing something obvious / if there's a workaround / if this is a known problem tracked in an existing issue.Thanks 🙂.
The text was updated successfully, but these errors were encountered: