diff options
| author | Martijn Cuppens <[email protected]> | 2020-11-25 22:12:32 +0200 |
|---|---|---|
| committer | XhmikosR <[email protected]> | 2020-12-06 18:42:40 +0200 |
| commit | d8f247392d203726a5d59404d96b54d8987fbc01 (patch) | |
| tree | 87581b7f23f03cfd7b294787a8d8565a9fecf0c2 /js/src | |
| parent | 444715744644965a977080fa7f74b4fed005cab5 (diff) | |
| download | bootstrap-d8f247392d203726a5d59404d96b54d8987fbc01.tar.xz bootstrap-d8f247392d203726a5d59404d96b54d8987fbc01.zip | |
Fix conflict with Bootstrap CSS
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/dropdown.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 04c299600..4e25f5729 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -57,7 +57,6 @@ const CLASS_NAME_SHOW = 'show' const CLASS_NAME_DROPUP = 'dropup' const CLASS_NAME_DROPEND = 'dropend' const CLASS_NAME_DROPSTART = 'dropstart' -const CLASS_NAME_MENUEND = 'dropdown-menu-end' const CLASS_NAME_NAVBAR = 'navbar' const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]' @@ -268,22 +267,23 @@ class Dropdown extends BaseComponent { _getPlacement() { const parentDropdown = this._element.parentNode - let placement = PLACEMENT_BOTTOM - // Handle dropup + if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) { + return PLACEMENT_RIGHT + } + + if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) { + return PLACEMENT_LEFT + } + + // We need to trim the value because custom properties can also include spaces + const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end' + if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) { - placement = this._menu.classList.contains(CLASS_NAME_MENUEND) ? - PLACEMENT_TOPEND : - PLACEMENT_TOP - } else if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) { - placement = PLACEMENT_RIGHT - } else if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) { - placement = PLACEMENT_LEFT - } else if (this._menu.classList.contains(CLASS_NAME_MENUEND)) { - placement = PLACEMENT_BOTTOMEND - } - - return placement + return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP + } + + return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM } _detectNavbar() { |
