Skip to content

Commit

Permalink
fix(modal): dimmer click closed modal when allowMultiple=true even if…
Browse files Browse the repository at this point in the history
… onHide()=false

Closes #284
  • Loading branch information
lubber-de authored and Sean committed Dec 18, 2018
1 parent 8ed0d08 commit 3146164
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/definitions/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,17 @@ $.fn.modal = function(parameters) {
isInModal = ($target.closest(selector.modal).length > 0),
isInDOM = $.contains(document.documentElement, event.target)
;
if(!isInModal && isInDOM && module.is.active()) {
if(!isInModal && isInDOM && module.is.active() && $module.hasClass(className.top) ) {
module.debug('Dimmer clicked, hiding all modals');
module.remove.clickaway();
if(settings.allowMultiple) {
module.hideAll();
if(!module.hideAll()) {
return;
}
}
else {
module.hide();
else if(!module.hide()){
return;
}
module.remove.clickaway();
}
},
debounce: function(method, delay) {
Expand Down Expand Up @@ -359,7 +361,7 @@ $.fn.modal = function(parameters) {
: function(){}
;
module.refreshModals();
module.hideModal(callback);
return module.hideModal(callback);
},

showModal: function(callback) {
Expand Down Expand Up @@ -441,7 +443,7 @@ $.fn.modal = function(parameters) {
module.debug('Hiding modal');
if(settings.onHide.call(element, $(this)) === false) {
module.verbose('Hide callback returned false cancelling hide');
return;
return false;
}

if( module.is.animating() || module.is.active() ) {
Expand Down Expand Up @@ -523,10 +525,17 @@ $.fn.modal = function(parameters) {
;
if( $visibleModals.length > 0 ) {
module.debug('Hiding all visible modals');
module.hideDimmer();
$visibleModals
.modal('hide modal', callback, false, true)
;
var hideOk = true;
//check in reverse order trying to hide most top displayed modal first
$($visibleModals.get().reverse()).each(function(index,element){
if(hideOk){
hideOk = $(element).modal('hide modal', callback, false, true);
}
});
if(hideOk) {
module.hideDimmer();
}
return hideOk;
}
},

Expand Down

0 comments on commit 3146164

Please # to comment.