Skip to content

Support Popper positions #22962

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
3 tasks
mdo opened this issue Jul 2, 2017 · 10 comments
Closed
3 tasks

Support Popper positions #22962

mdo opened this issue Jul 2, 2017 · 10 comments

Comments

@mdo
Copy link
Member

mdo commented Jul 2, 2017

Replacement issue for #17759 and #19921. Would be rad to tackle this for a v4.1 or v4.2 release.

Also includes dropdowns now: #21510.

  • Tooltips
  • Popovers
  • Dropdown

/cc @Johann-S

@pat270
Copy link
Contributor

pat270 commented Jul 27, 2017

Can we get more dropdown-menu positions as well?

dropdown-positions

@Acts7
Copy link

Acts7 commented Feb 22, 2018

Bootstrap 4's dropdown placement options currently mirror the "basic" positioning for popper.
EXCEPT:
position: 'bottom'.
Why was that left off and how can we get that replaced?

// 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;
};

@itsjavi
Copy link

itsjavi commented Jul 23, 2018

Popper supports placement variations using -end and -start, e.g.: bottom-end (which means bottom left alignment).

Is this issue going to address that problem? It seems that it is not supported via de BS popover options (I am using the 4.1.2 bundle JS).

@kikonen
Copy link

kikonen commented Apr 8, 2019

Just hit this "-start" & "-end" problem with bootstrap 4.3.1. I would need to definitely be able to use "top-start" alignment for some tooltips, but bootstrap tooltip.js explicitly forbids that.

So I'm pondering what kind of workaround would solve the problem.

Found workaround, just overriding placement resolver from "Tooltip class"

var AttachmentMap = {
  AUTO: 'auto',
  TOP: 'top',
  RIGHT: 'right',
  BOTTOM: 'bottom',
  LEFT: 'left',
  'TOP-START': 'top-start'
};

window.Tooltip.prototype._getAttachment = function(placement) {
  return AttachmentMap[placement.toUpperCase()];
};

@Jule-
Copy link

Jule- commented Apr 8, 2020

Still opened...

My little 2cts workaround, include/execute after bootstrap.js is loaded:

;(function () {
  // Fix Bootstrap caveat regarding to Poppers.js placement capabilities
  // Allow overriding Dropdown placement with 'data-placement' attribute
  var original_getPlacement = bootstrap.Dropdown.prototype._getPlacement
  bootstrap.Dropdown.prototype._getPlacement = function () {
    return $(this._menu).data('placement') || original_getPlacement()
  }
})()

then for example:

<div className="dropdown-menu" data-placement="bottom">
  ...
</div>

@tszalbot
Copy link

+1

@transfer1992
Copy link

Still opened...

My little 2cts workaround, include/execute after bootstrap.js is loaded:

;(function () {
  // Fix Bootstrap caveat regarding to Poppers.js placement capabilities
  // Allow overriding Dropdown placement with 'data-placement' attribute
  var original_getPlacement = bootstrap.Dropdown.prototype._getPlacement
  bootstrap.Dropdown.prototype._getPlacement = function () {
    return $(this._menu).data('placement') || original_getPlacement()
  }
})()

then for example:

<div className="dropdown-menu" data-placement="bottom">
  ...
</div>

That worked for me! Thanks!

@adrianoresende
Copy link

Why in 5 version don't have class dropdown-menu-center to simplify?

@mc-caprice
Copy link

Why are all the other issues closed regarding this? I was hoping to use this as a closed issue means problem solved?

@mdo
Copy link
Member Author

mdo commented Mar 16, 2022

Added center dropdown and dropup variations in #35893, so going to close this out. I don't see us adding every single option at this point, but if someone does want to go the extra length to try it out for us, I'm down to review a PR :).

@mdo mdo closed this as completed Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants