bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Button dropdown links don't work on mobile (android, iOS)

Open MikiMullor opened this issue 14 years ago • 192 comments

I have simple dropdown buttons we built with 2.04

links are A tags, proper quotes, href='#'

Used to work fine.

Upgraded today to 2.1 and the links in any dropdown button don't work. The dropdown menu opens, but clicking on a link closes the menu without any action. tested on Android 2.3 and iOS 5

Rolledback to 2.04 and everything works again. Anyone else has this issue?

MikiMullor avatar Aug 22 '12 04:08 MikiMullor

Same problem here for me. Menu opens, but clicking simply close it. Tested on iPad IOS 5.1

Stefac avatar Aug 22 '12 15:08 Stefac

Would like to add that the dropdown menus from a navbar do work on a iPad (iOS 6), but like the other 2 posters they are not working on a dropdown button.

jwilson avatar Aug 23 '12 18:08 jwilson

A quick hack to prevent the dropdown menu from being cleared on touch devices:

on line 143 of bootstrap-dropdown.js replace

.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)

with

.on('click.dropdown.data-api', clearMenus)

You won't be able to tap outside the menu to close it, but the dropdown links will work.

dpwolf avatar Aug 23 '12 23:08 dpwolf

+1

Looking forward to the fix in 2.1.1

ShivX avatar Aug 27 '12 21:08 ShivX

Hey @MikiMullor,

Thanks for opening this issue! Unfortunately, it looks like it fails to pass the criteria neccessary for submitting to bootstrap. The following things are currently failing:

  • should include a jsfiddle/jsbin illustrating the problem if tagged with js but not a feature

For a full list of issue filing guidelines, please refer to the bootstrap issue filing guidelines.

thanks!

fat avatar Aug 27 '12 22:08 fat

@fat

This seems counter-productive. The issue can be repeated on the bootstrap sample page, and it's pretty critical that Bootstrap button dropdown links don't work on touch devices! :-/

If it means getting it fixed in 2.1.1, Here's a JSFiddle

ShivX avatar Aug 28 '12 10:08 ShivX

@ShivX thanks!

dpwolf avatar Aug 28 '12 14:08 dpwolf

+1 here.

Looking forward to the fix. Any foreseeable release date for it?

  Edit: For those interested, this is my little "workaround" that seems to work, add it after the "bootstrap-dropdown.js" include (I put mine in the $(function() { } section which is located at the end of the page in my case):

$('a.dropdown-toggle').on('touchstart', function(e) {
      // do your stuff here
})

Zylinderkatze avatar Sep 04 '12 14:09 Zylinderkatze

Still an issue in 2.1.1. Demo can be found in gh-pages.

Starefossen avatar Sep 05 '12 10:09 Starefossen

Have also tested with 2.1.1. Dropdown menu links do not work on IOS devices running 5.1.1. They work fine when using RWD Bookmarklet or responsive.is for testing, just not natively on IOS devices.

babrewer avatar Sep 05 '12 14:09 babrewer

I'm having this issue too. Very much interested in a fix.

mikegreiling avatar Sep 06 '12 02:09 mikegreiling

Having the issue in Chrome Desktop with v.2.1.1 @dpwolf solution worked for us (aka removing touchstart event in that line).

The problem is that both events 'click' and 'touchstart' are triggered. First "touchstart" event and then, 300 ms later comes up the 'click' event .. so clearMenu is called twice.

Probably I'm wrong.. but it's like the browser doesn't have time to handle the 'a' link as normally because touchstart already cleared the menus.

Is there any other solution than treat those 2 event types separetly ? More info https://developers.google.com/mobile/articles/fast_buttons?hl=de-DE

dcorb avatar Sep 06 '12 11:09 dcorb

Same problem for me with Bootstrap 2.1.1 on iOS 6 :-(

patrickoehlinger avatar Sep 08 '12 22:09 patrickoehlinger

I'm experiencing this issue as well :(

tonybruess avatar Sep 09 '12 16:09 tonybruess

Pull #4812 looks to address this

thezoggy avatar Sep 09 '12 16:09 thezoggy

Pull #4812 didn't fix dropdown links on iOS for me. It seems the default event is still being prevented.

ghost avatar Sep 09 '12 17:09 ghost

Also have this problem on IOS 6.

crag avatar Sep 09 '12 21:09 crag

I'll fix this up in my PR later today. Shouldn't require too much of a change to get this working as expected.

blakeembrey avatar Sep 10 '12 04:09 blakeembrey

I seem to have a better workaround by adding this line after the line dpwolf mentioned, rather than changing the line:

$('.dropdown-menu').on('touchstart.dropdown.data-api', function(e) { e.stopPropagation() })

I haven't noticed any side effects so far.

stevecoug avatar Sep 11 '12 04:09 stevecoug

@fridgesm Pretty much the same thing I did for my fix in #5067 - However you should bind it to the body otherwise it won't get triggered on any dropdowns after you call that line. Should be a better solution to this, just can't think of on right now

blakeembrey avatar Sep 11 '12 09:09 blakeembrey