Skip to content

Bootstrap 4 Dropdown Centering | AttachmentMap 'bottom' Placement is missing #25627

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

Closed
Acts7 opened this issue Feb 14, 2018 · 1 comment
Closed

Comments

@Acts7
Copy link

Acts7 commented Feb 14, 2018

This has been covered in many requests but no one has provided an easy solution.
Here is the issue:
Many want to option to center align the dropdown.
(Sure it can be hardcoded with css positioning but that is bad practice as it doesn't take use of the popper.js extension keeping content within the screen boundaries).

ANSWER:
IT ALREADY EXISTS, someone just forgot it when creating the AttachmentMap.

I've tested the below code and it indeed works.

SOLUTION:
// affected files dropdown.js (which is somehow built into bootstrap.bundle.js so that file as well)

// approx line 48
var ClassName = {
....
//add this line:
MENUCENTER: 'dropdown-menu-center',  // add new css class for center align dropdown
....
};

// approx line 65
var AttachmentMap = {
....
//add this line:
BOTTOMCENTER: 'bottom',    // 'bottom' already exists in popper.js. this just maps to that placement.
....
};

// approx 227
_proto._getPlacement = function _getPlacement() {
  ....
//add these 3 lines
  } else if ($(this._menu).hasClass(ClassName.MENUCENTER)) {
    placement = AttachmentMap.BOTTOMCENTER;
  }
 ....
  return placement;
};

Thats it. A total of FIVE lines will give everyone the ability to center their dropdowns.
HOW?? can this be added?

@Acts7 Acts7 changed the title Bootstrap 4 dropdown AttachmentMap 'bottom' (which centers the dropdown) Bootstrap 4 Dropdown Centering | AttachmentMap 'bottom' Placement is missing Feb 15, 2018
@Johann-S
Copy link
Member

Related to : #22962

Please make a PR 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants