diff options
author | Troy Morehouse <troymore@nbnet.nb.ca> | 2017-12-12 12:28:30 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2017-12-12 12:28:30 +0300 |
commit | 8839c03865f02cf9c98443f4e07ac477985151ed (patch) | |
tree | 6fb5b971ca225f392d9b051a9824517583767911 /js/src/dropdown.js | |
parent | a7e64c84aec65fe38b5a9323638e62d513b64ce8 (diff) |
dropdown: add boundary config option (#24976)
Diffstat (limited to 'js/src/dropdown.js')
-rw-r--r-- | js/src/dropdown.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 8affedc6ce..56559b4345 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -50,7 +50,8 @@ const Dropdown = (($) => { DROPRIGHT : 'dropright', DROPLEFT : 'dropleft', MENURIGHT : 'dropdown-menu-right', - MENULEFT : 'dropdown-menu-left' + MENULEFT : 'dropdown-menu-left', + POSITION_STATIC : 'position-static' } const Selector = { @@ -74,12 +75,14 @@ const Dropdown = (($) => { const Default = { offset : 0, - flip : true + flip : true, + boundary : 'scrollParent' } const DefaultType = { offset : '(number|string|function)', - flip : 'boolean' + flip : 'boolean', + boundary : '(string|element)' } @@ -159,6 +162,12 @@ const Dropdown = (($) => { element = parent } } + // If boundary is not `scrollParent`, then set position to `static` + // to allow the menu to "escape" the scroll parent's boundaries + // https://github.com/twbs/bootstrap/issues/24251 + if (this._config.boundary !== 'scrollParent') { + $(parent).addClass(ClassName.POSITION_STATIC) + } this._popper = new Popper(element, this._menu, this._getPopperConfig()) } @@ -276,6 +285,9 @@ const Dropdown = (($) => { offset : offsetConf, flip : { enabled : this._config.flip + }, + preventOverflow : { + boundariesElement : this._config.boundary } } } |