diff --git a/js/angular/service/modal.js b/js/angular/service/modal.js index a83cea8bed9..4e3c9f41f4e 100644 --- a/js/angular/service/modal.js +++ b/js/angular/service/modal.js @@ -251,10 +251,24 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl * @returns {promise} A promise which is resolved when the modal is finished animating out. */ remove: function() { - var self = this; + var self = this, + deferred, promise; self.scope.$parent && self.scope.$parent.$broadcast(self.viewType + '.removed', self); - return self.hide().then(function() { + // Only hide modal, when it is actually shown! + // The hide function shows a click-block-div for a split second, because on iOS, + // clicks will sometimes bleed through/ghost click on underlying elements. + // However, this will make the app unresponsive for short amount of time. + // We don't want that, if the modal window is already hidden. + if (self._isShown) { + promise = self.hide(); + } else { + deferred = $$q.defer(); + deferred.resolve(); + promise = deferred.promise; + } + + return promise.then(function() { self.scope.$destroy(); self.$el.remove(); });