bug: Modal windows open and then close suddenly
Type: bug
Platform: android 4.4 webview
My app was updated to the 1.0 release and I started having issues with modal windows opening on 4.4.2 android devices.
I have a modal service that manages opening/closing/cleanup for modal windows and all modals are having this issue. The modal will open and then quickly close without any interaction from the user. You can see the open/close animations happen.
If I look at the console with dev tools for the device, I get an error that states "Uncaught TypeError: Cannot read property 'offsetX' of null". The error occurs in the ionSideMenuContent directive's content variable/object's setTranslateX() function:
var content = {
element: element[0],
onDrag: function() {},
endDrag: function() {},
getTranslateX: function() {
return $scope.sideMenuContentTranslateX || 0;
},
setTranslateX: ionic.animationFrameThrottle(function(amount) {
var xTransform = content.offsetX + amount; // <- ERROR HERE!
$element[0].style[ionic.CSS.TRANSFORM] = 'translate3d(' + xTransform + 'px,0,0)';
$timeout(function() {
$scope.sideMenuContentTranslateX = amount;
});
}),
// ....
}
Here's a codepen with an example of the usage of my modalService.
http://codepen.io/anon/pen/XbgEpX
It works in the browser but the issue happens in android 4.4.2 so I'm not sure how helpful this will be.
Should I report issues here or in the ionic forums to get help?
I just tried this with an android 4.4.2 device and wasn't able to replicate the issue using the nightly builds. Do you have anymore information that you could provide?
Did you try it with 1.0.1 stable? The codepen was pointing to 1.0.0 when it was created because it was before 1.0.1 was released.
Yes, I tried with both 1.0.1 and the nightly builds.
Mike Hartington
On Jul 29, 2015, at 2:26 PM, 3melectronicmonitoring [email protected] wrote:
Did you try it with 1.0.1 stable? The codepen was pointing to 1.0.0 when it was created because it was before 1.0.1 was released.
— Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic/issues/3923#issuecomment-126049786.
Just in case someone else runs into this, we solved our issue by setting backdropClickToClose = false.
For us, it was a sporadic problem that only happened on our Android 4.4.2 device and we could not get the error to happen in a simple test code.
Adding a bunch of debug statements found that the click event for opening the window was also getting called for closing the window and it seemed to think there was a click in the backdrop to close.
We traced it to this block of code in ionic-angular.js
return $timeout(function() {
if (!self._isShown) return;
//After animating in, allow hide on backdrop click
self.$el.on('click', function(e) {
if (self.backdropClickToClose && e.target === self.el && stack.isHighest(self)) {
self.hide();
}
});
}, 400);
We suspect it has something to do with the animation speed and that 400ms delay. Perhaps someone else will find more details.
Greetings @3melectronicmonitoring!
My sensors indicate a reply was requested, but as we have not received one yet, I am using my robot powers to close this issue. However, if you are still experiencing this issue, please feel free to reopen it by creating a new issue, and include any examples or necessary information.
Thank you for allowing me to assist you.