Skip to content

Commit

Permalink
fix: issue with some modals not closing, fixes #925
Browse files Browse the repository at this point in the history
  • Loading branch information
akinsey committed Sep 28, 2020
1 parent 10d7cb3 commit e46dd15
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions modules/ept-frontend/client/components/modal/modal.directive.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = ['$document', function($document) {
module.exports = ['$document', '$timeout', function($document, $timeout) {
return {
restrict: 'E',
scope: {
Expand All @@ -16,20 +16,35 @@ module.exports = ['$document', function($document) {
'</div>' +
'</div>',
link: function(scope) {
scope.listener = false;
scope.focus = false;
scope.close = function() {
scope.focus = false;
scope.show = false;
if (scope.form) {
scope.form.$setPristine();
scope.form.$setUntouched();
}
if (scope.onClose) { scope.onClose(); }
$timeout(function() {
scope.focus = false;
scope.show = false;
if (scope.form) {
scope.form.$setPristine();
scope.form.$setUntouched();
}
if (scope.onClose) { scope.onClose(); }
$document[0].body.style.overflow = 'hidden auto';
$timeout(function() {
if(scope.listener) {
$(document).off('keydown');
scope.listener = false;
}
});
});
};
scope.$watch('show', function(show) {
if (show) {
scope.focus = true;
$document[0].body.style.overflow = 'hidden';
$document[0].body.style.overflow = 'hidden hidden';
if (!scope.listener) {
$(document).on('keydown', function(e) {
if (e.which == 27 && scope.show) { scope.close(); }
});
}
}
else {
scope.close();
Expand Down

0 comments on commit e46dd15

Please sign in to comment.