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 menus don't get closed when selecting an option #4497

Closed
lrlopez opened this issue Aug 21, 2012 · 21 comments
Closed

Dropdown menus don't get closed when selecting an option #4497

lrlopez opened this issue Aug 21, 2012 · 21 comments
Labels
Milestone

Comments

@lrlopez
Copy link

lrlopez commented Aug 21, 2012

[Tested on Chrome 21, Safari 6 and Firefox 14]

I've upgraded Bootstrap on a test-branch and dropdown menus no longer close automatically once an option is selected. User has to click outside for the menu to disappear.

The problem is reproducible in the official docs: http://twitter.github.com/bootstrap/javascript.html#dropdowns

Did I miss something on the changelog about this new behaviour? If this is a "WON'T FIX", is there any workaround to force them to close?

@kr3l
Copy link

kr3l commented Aug 22, 2012

I have the same problem. Dropdowns used to close automatically when selecting an option, after upgrade to 2.1.0 they do not close anymore when an option is selected.

@lphm
Copy link

lphm commented Aug 23, 2012

I have several dropdown into a navbar and it's always the first initialized who works well. Others do not want to close when I choose (click) an option OR if I click somewhere else on the page to close it.

The problem is here since the 2.1 version.

@jon301
Copy link

jon301 commented Aug 23, 2012

Hi,

Same problem for me :

http://jsfiddle.net/7ptXA/

@zachlowry
Copy link

I've commented on the line of code that caused this here: c9cef74#js/bootstrap-dropdown.js. Change the target for the event to ".dropdown form" and it should be fixed.

@kr3l
Copy link

kr3l commented Aug 23, 2012

@zachlowry This fixes the issue for me, thanks

@jasonkreider
Copy link

Removing "form" from the selector also prevents menu items using rails jquery_ujs from working (e.g. :method => :delete for a sign out link).

@mhuggins
Copy link

+1 on this issue

@internalfx
Copy link

+1 on this issue

@mfansler
Copy link
Contributor

Here's an interim solution until the 2.1.1 comes through:

$('body')
  .off('click.dropdown touchstart.dropdown.data-api', '.dropdown')
  .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })

Edit: I should add, in case it's not clear, that this workaround is really only intended for those loading Bootstrap off a CDN. If you're hosting your own code, just fix it directly. :P

@mhuggins
Copy link

Thanks for the workaround!

@benrhere
Copy link

+1 on this...

@tonybruess
Copy link

+1 for me too. Glad I'm not the only one that was confused.

@ShivX
Copy link

ShivX commented Aug 27, 2012

I'm somewhat confused as to why 4756 was closed - the fix listed above does NOT fix that specific issue?

EDIT: Never mind, probably in reference to 4550

@fat fat closed this as completed Aug 27, 2012
@fat fat reopened this Aug 27, 2012
@fat
Copy link
Member

fat commented Aug 28, 2012

added the form bit back, which fixes this – will look into another way of handling the mobile stuff

@fat fat closed this as completed Aug 28, 2012
@mhuggins
Copy link

@fat - I'm not seeing the commit in the Github commits that fixes this. Am I missing something?

@mfansler
Copy link
Contributor

@mhuggins
Copy link

Ahh, didn't realize that's how Twitter does it. Thanks!

@ybart
Copy link

ybart commented Aug 31, 2012

A temporary workaround can be found here for incompatibilty with jquery-rails while waiting 2.1.1 release : seyhunak/twitter-bootstrap-rails#343

@RusAlex
Copy link

RusAlex commented Oct 10, 2012

the same issue

@marcelometal
Copy link

$('.dropdown-menu select, .dropdown-menu textearea').click(function(e) {
e.stopPropagation();
})

AramZS added a commit to PressForward/pressforward that referenced this issue Mar 2, 2015
@reunix
Copy link

reunix commented Dec 15, 2015

perfect marcelometal!!!

@twbs twbs locked and limited conversation to collaborators Dec 17, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests