Skip to content

Commit b0c89ef

Browse files
committed
fix(modal): Don't show click-block-div unnecessarily on remove()
1 parent 72a50b3 commit b0c89ef

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Diff for: js/angular/service/modal.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,24 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl
251251
* @returns {promise} A promise which is resolved when the modal is finished animating out.
252252
*/
253253
remove: function() {
254-
var self = this;
254+
var self = this,
255+
deferred, promise;
255256
self.scope.$parent && self.scope.$parent.$broadcast(self.viewType + '.removed', self);
256257

257-
return self.hide().then(function() {
258+
// Only hide modal, when it is actually shown!
259+
// The hide function shows a click-block-div for a split second, because on iOS,
260+
// clicks will sometimes bleed through/ghost click on underlying elements.
261+
// However, this will make the app unresponsive for short amount of time.
262+
// We don't want that, if the modal window is already hidden.
263+
if (self._isShown) {
264+
promise = self.hide();
265+
} else {
266+
deferred = $$q.defer();
267+
deferred.resolve();
268+
promise = deferred.promise;
269+
}
270+
271+
return promise.then(function() {
258272
self.scope.$destroy();
259273
self.$el.remove();
260274
});

0 commit comments

Comments
 (0)