From bec97f84a2239862a6249cea3938dc8b19d3f1da Mon Sep 17 00:00:00 2001 From: wdg100 Date: Sun, 15 Dec 2019 15:48:29 +0800 Subject: [PATCH] fix close issue during an action when swiped into backdrop --- src/js/bootstrap-dialog.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/js/bootstrap-dialog.js b/src/js/bootstrap-dialog.js index b613564..d97578c 100644 --- a/src/js/bootstrap-dialog.js +++ b/src/js/bootstrap-dialog.js @@ -319,10 +319,21 @@ BootstrapDialog.METHODS_TO_OVERRIDE = {}; BootstrapDialog.METHODS_TO_OVERRIDE['v3.1'] = { handleModalBackdropEvent: function () { - this.getModal().on('click', {dialog: this}, function (event) { - event.target === this && event.data.dialog.isClosable() && event.data.dialog.canCloseByBackdrop() && event.data.dialog.close(); + var dropbackClicked = 0; + this.getModal().on('mousedown', {dialog: this}, function (event) { + if (event.target === this) { + dropbackClicked++; + } else { + dropbackClicked = 0; + } + }); + this.getModal().on('mouseup', {dialog: this}, function (event) { + if (event.target === this && dropbackClicked > 0) { + dropbackClicked++; + event.data.dialog.isClosable() && event.data.dialog.canCloseByBackdrop() && event.data.dialog.close() + } + dropbackClicked = 0; }); - return this; }, /**