Skip to content

Commit

Permalink
Pressing the ESC key won't close all open modals anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
prudho committed Sep 13, 2018
1 parent e09a4ed commit 41180a7
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/definitions/modules/modal.js
Expand Up @@ -288,7 +288,9 @@ $.fn.modal = function(parameters) {
if(keyCode == escapeKey) {
if(settings.closable) {
module.debug('Escape key pressed hiding modal');
module.hide();
if ( $module.hasClass(className.top) ) {
module.hide();
}
}
else {
module.debug('Escape key pressed, but closable is set to false');
Expand Down Expand Up @@ -400,6 +402,8 @@ $.fn.modal = function(parameters) {
if( module.is.animating() || module.is.active() ) {
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
module.remove.active();
$otherModals.filter('.' + className.active).last().addClass(className.top)
$module.removeClass(className.top);
$module
.transition({
debug : settings.debug,
Expand All @@ -411,7 +415,7 @@ $.fn.modal = function(parameters) {
if(!module.others.active() && !keepDimmed) {
module.hideDimmer();
}
if(settings.keyboardShortcuts) {
if( settings.keyboardShortcuts && !module.others.active() ) {
module.remove.keyboardShortcuts();
}
},
Expand Down Expand Up @@ -690,7 +694,8 @@ $.fn.modal = function(parameters) {
}
},
active: function() {
$module.addClass(className.active);
$module.addClass(className.active + ' ' + className.top);
$otherModals.filter('.' + className.active).removeClass(className.top)
},
scrolling: function() {
$dimmable.addClass(className.scrolling);
Expand Down Expand Up @@ -972,7 +977,8 @@ $.fn.modal.settings = {
inverted : 'inverted',
loading : 'loading',
scrolling : 'scrolling',
undetached : 'undetached'
undetached : 'undetached',
top : 'top'
}
};

Expand Down

0 comments on commit 41180a7

Please sign in to comment.