Skip to content
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

Dropdown can open offscreen laterally #13477

Closed
caseyWebb opened this issue May 1, 2014 · 6 comments
Closed

Dropdown can open offscreen laterally #13477

caseyWebb opened this issue May 1, 2014 · 6 comments

Comments

@caseyWebb
Copy link

A picture is worth a thousand words; this is taken directly from the docs with chrome at 515px wide.

image

I've implemented the following solution in my own project to remedy this, and would like to know if it is worth submitting a pull request for (modified, of course)

$(document).on('shown.bs.dropdown', function () {
  OffsetDropdown()

  $(window).on('resize.bs.dropdown', function () {
    OffsetDropdown()
  })
})

$(document).on('hide.bs.dropdown', function() {
  $(window).off('resize.bs.dropdown')
})

var OffsetDropdown = function() {
  var dropdown = $('.open>.dropdown-menu')

  if (dropdown.length == 0)
    return

  var rightOffset = dropdown.offset().left + dropdown.width()
  var browserWidth = $('body').innerWidth()
  var neededLeftOffset = dropdown.position().left - (rightOffset - browserWidth)

  if (neededLeftOffset < 0) {
    dropdown.css({ left: neededLeftOffset - 3 })
  } else {
    dropdown.css({ left: 0 })
  }
}
@cvrebert
Copy link
Collaborator

cvrebert commented May 1, 2014

X-Ref: #10756

@cvrebert cvrebert changed the title Dropdown can open offscreen Dropdown can open offscreen laterally May 4, 2014
@cvrebert cvrebert added this to the v3.2.1 milestone May 22, 2014
@mdo
Copy link
Member

mdo commented Jul 6, 2014

Maybe we punt to v4 given we might redo dropdowns then?

@mdo
Copy link
Member

mdo commented Aug 2, 2014

Punting to the v4 checklist.

@NTMan
Copy link

NTMan commented Aug 21, 2014

Don't understand this issue already fixed or not?
If fixed in which version?

@juthilo
Copy link
Collaborator

juthilo commented Aug 21, 2014

@NTMan This issue will be considered when we work on the next version of Bootstrap, v4.

@mdo mdo mentioned this issue Aug 19, 2015
@spaquet
Copy link

spaquet commented Mar 9, 2017

Still not properly supported in V4.
image

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

6 participants