Prevent closing modals when mouse drags outside

This commit is contained in:
JonnyWong16 2021-04-29 10:01:54 -07:00
parent 6a575824ef
commit fc3a81a622
No known key found for this signature in database
GPG key ID: B1F1F9807184697A

View file

@ -911,3 +911,20 @@ function toggleRevealTokens() {
$('body').on('click', '.reveal-token', function() {
_toggleRevealToken($(this), true);
});
// https://stackoverflow.com/a/57414592
// prevent modal close when click starts in modal and ends on backdrop
$(document).on('mousedown', '.modal', function(e){
window.clickStartedInModal = $(e.target).is('.modal-dialog *');
});
$(document).on('mouseup', '.modal', function(e){
if(!$(e.target).is('.modal-dialog *') && window.clickStartedInModal) {
window.preventModalClose = true;
}
});
$('.modal').on('hide.bs.modal', function (e) {
if(window.preventModalClose){
window.preventModalClose = false;
return false;
}
});