bug: click/tap firing twice on iOS
Type: bug
Ionic Version: 1.x
Platform: ios 9 webview
Hi
I have a page with 3 checkboxes and 2 buttons. When the user clicks/taps on them, sometimes it's like there were two clicks instead of one... It seems that the Ionic Tap system is triggering 2 ng-click events.
This only happens on iOS (for example: ios simulator : iphone 5, 8.4) and on iOS devices.
Very similar to this bug https://github.com/driftyco/ionic/issues/5591.
Thanks a lot.
$ ionic info
Your system information:
Cordova CLI: 5.3.3
Ionic Version: 1.2.1
Ionic CLI Version: 1.7.12
Ionic App Lib Version: 0.6.5
ios-deploy version: 1.8.2
ios-sim version: 5.0.3
OS: Mac OS X El Capitan
Node Version: v4.2.1
Xcode version: Xcode 7.1 Build version 7B91b</span>
Please provide a codepen or plunk demo to test against
Hi @mhartington, thanks for your message. But I can't, I don't know how to do this on codepen, I discussed this a bit with @brandyshea and I sent her a part of my code.
I made a new minimum version in the branch called minimalistDoubleClickBug.
I am sending it to you right now in a private message.
Hi, I made a codePen: http://codepen.io/LouisDoe/pen/gPvGXe?editors=1000
Can I do something else ?
I am having the same issue
Hi @JSONMartin, thanks for backing up the issue. I've tried my best to get the attention of the Ionic team. I built a codepen, but if I simplify too much the code, the error disappear. Do you think you could make a CodePen with the issue ?
same + 1
Hi could anyone from ionic check this ?
In my case I had to put a $timeout in the ng-change function of my checkboxes to make it work....
$scope.onchangeCheckbox = function() {
$timeout(function(){
$scope.filterItems();
$scope.scrollCollectionTop();
$ionicLoading.hide();
},400);
}
I'm having the same sort of issue on a couple of items. If I have a button bar, tapping a single button taps it twice. Also, if I'm using a SweetAlert and a select box or input field is behind one of the buttons, it will open that box or the keyboard if the confirmation button is on top of it.
The work around I'm using currently is similar to yours. For the button bar, I stole a custom ngClick directive from stack overflow.
export function myClick(): ng.IDirective {
return {
link: ($scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes) => {
var unbindFunc: JQuery = element.bind('touchstart click', function(event) {
event.preventDefault();
event.stopPropagation();
$scope.$apply(attrs["myClick"]);
});
element.on("$destroy", function() {
unbindFunc.unbind();
$scope.$destroy();
});
}
};
}
And for the SweetAlert thing, I've just been using the $ionicClickBlock factory like so.
swal({
title: "Continue?",
text: "Would you like to continue?",
showCancelButton: true,
confirmButtonText: "Yes",
cancelButtonText: "No",
closeOnConfirm: false
}, (confirmed) => {
// fixes tap bleed through
ctrl.$ionicClickBlock.show(500);
if (confirmed) {
deferred.resolve(true);
} else {
deferred.reject();
}
});
I've only seen this issue in iOS because of the UIWebView or whatever it is not correctly dealing with the 300ms tap delay. I can produce a codepen if needed.
We encounter same issue for an app on iOS. Adding event.preventDefault() and event.stopPropagation(); within the ng-click handler is fixing it. We'll try to get some more details, but for now it seems like a temp fix for us.
Hi @louisdoe (and others),
I am looking at your codepen. Can you give me the steps I need to take to recreate the issue in the codepen? I will try to come up with a fix for the next release of Ionic 1.x
Thanks, Dan
Hi @louisdoe, if it's easier you can send me the private branch and give me access. Either way works. Just let me know.
Hi @louisdoe, you code pen does not work.
@dually8, @mitiaptest, @vadimpopa, @JSONMartin, do any of you have a codepen or similar that will allow me to easily recreate the issue?
Thanks, Dan
I don't, we caught it in our client's app which code is private. Since we are working for release I don't have time to prepare a test case. Forgot to mention that on our side is happening on 1.1.1, I'll test later this week on 1.2.4 and let you know.
I haven't been able to replicate it since cordova iOS 4.1.0 and iOS 9.3.1. Regardless, below is a codepen of more or less what I had previously. But like I said, I haven't been able to replicate this since the updates. I'm not sure about anyone else in the thread.
http://codepen.io/dually8/pen/VaQQbE
@dually8, can you give me step by step instructions on what to click in your codepen to see the bug? I understand you haven't been able to replicate it with newer versions of iOS and cordova iOS. Am I suppose to see duplicate clicks (in theory) when clicking the "ayy" button?
Thanks, Dan
When clicking the button bar and/or the "ayy" buttons. Like I said though, I haven't been able to replicate this since the Cordova and iOS updates.
@dually8, thanks, I appreciate the response.
Hello all,
I am happy to reopen this issue if we have a codepen or something that we can consistently reproduce it with. @louisdoe, please respond to this post if you'd like me to continue investigating but we need something a little more concrete to go off of. I cannot presently recreate the issue.
Thanks, Dan
We tested our app on 1.2.4, iOS 9.3.1 & iPhone 5 (only on this device is reproducible), and we couldn't reproduce it, seems that it's an 1.1.1 issue only.