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 menu does not close #72

Closed
egmen opened this issue Sep 19, 2016 · 5 comments
Closed

Dropdown menu does not close #72

egmen opened this issue Sep 19, 2016 · 5 comments
Labels
invalid not related or critical

Comments

@egmen
Copy link

egmen commented Sep 19, 2016

Dropdown menu does not close after clicking any meny item.
This happens even on example http://thednp.github.io/bootstrap.native/#exampleDropdown in every browser, I've checked IE11, Chrome and Firefox.
Original bootstrap javascript has such behavior and works well http://getbootstrap.com/javascript/#dropdowns

@thednp
Copy link
Owner

thednp commented Sep 19, 2016

Indeed, our implementation here is a bit different, slightly more simple, it handles forms inside dropdown-menu where the original script doesn't showcase this kind of feature, and when the click target is a link, it goes to that link.

But the main reason is the ability to handle forms inside dropdown-menu.

@thednp thednp closed this as completed Sep 19, 2016
@thednp thednp added the invalid not related or critical label Sep 19, 2016
@pors
Copy link

pors commented Nov 26, 2016

Hi @thednp, awesome library! Saves me many bytes :)

So what is the solution if you want it to close on clicking a menu item? E.g. in case you use named anchors?

@thednp
Copy link
Owner

thednp commented Nov 26, 2016

@pors You can always fork the script and do something like this:

if ( target === self.menu || target.parentNode === self.menu || target.parentNode.parentNode === self.menu 
       || (/\#/.test(target.href) || /\#/.test(target.parentNode.href)) ) {
    self.toggle(e);
}  else if ( children && children.indexOf(target) > -1  ) {
    return;
} else { self.close(); }

Haven't tested but you probably get the point.

@pors
Copy link

pors commented Nov 26, 2016

Wow, that's a fast answer :)

Will do what you propose, thanks!

@thednp
Copy link
Owner

thednp commented Jan 15, 2017

@pors and @egmen the future version will have an option to control this behavior.

By default the new option will be disabled false which will make the Dropdown same as before, but when true, it will not close, as you know it is now, and even better.

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

No branches or pull requests

3 participants