diff options
author | Martijn Cuppens <martijn.cuppens@gmail.com> | 2020-11-25 23:12:32 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2020-12-06 19:42:40 +0300 |
commit | d8f247392d203726a5d59404d96b54d8987fbc01 (patch) | |
tree | 87581b7f23f03cfd7b294787a8d8565a9fecf0c2 /js/src/dropdown.js | |
parent | 444715744644965a977080fa7f74b4fed005cab5 (diff) |
Fix conflict with Bootstrap CSS
Diffstat (limited to 'js/src/dropdown.js')
-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 04c299600e..4e25f57299 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() { |