diff --git a/addons/web/static/src/js/core/dialog.js b/addons/web/static/src/js/core/dialog.js index e3101e52bde..63b33497cd3 100644 --- a/addons/web/static/src/js/core/dialog.js +++ b/addons/web/static/src/js/core/dialog.js @@ -53,8 +53,8 @@ var Dialog = Widget.extend({ * @param {jQueryElement} [options.$parentNode] * Element in which dialog will be appended, by default it will be * in the body - * @param {boolean} [options.backdrop=true] - * Whether modal rendered with backdrop or not + * @param {boolean|string} [options.backdrop='static'] + * The kind of modal backdrop to use (see BS documentation) * @param {boolean} [options.renderHeader=true] * Whether or not the dialog should be rendered with header * @param {boolean} [options.renderFooter=true] @@ -75,7 +75,7 @@ var Dialog = Widget.extend({ buttons: [{text: _t("Ok"), close: true}], technical: true, $parentNode: false, - backdrop: true, + backdrop: 'static', renderHeader: true, renderFooter: true, }); diff --git a/addons/web/static/tests/core/widget_tests.js b/addons/web/static/tests/core/widget_tests.js index 13515e08641..fabda247938 100644 --- a/addons/web/static/tests/core/widget_tests.js +++ b/addons/web/static/tests/core/widget_tests.js @@ -3,6 +3,7 @@ odoo.define('web.widget_tests', function (require) { var AjaxService = require('web.AjaxService'); var core = require('web.core'); +var Dialog = require('web.Dialog'); var QWeb = require('web.QWeb'); var Widget = require('web.Widget'); var testUtils = require('web.test_utils'); @@ -482,6 +483,24 @@ QUnit.module('core', {}, function () { assert.verifySteps(['destroy'], "child should have been detroyed only once"); }); + + QUnit.module('Widgets, Dialog'); + + QUnit.test("don't close dialog on backdrop click", async function (assert) { + assert.expect(3); + + var dialog = new Dialog(null); + dialog.open(); + await dialog.opened(); + + assert.strictEqual($('.modal.show').length, 1, "a dialog should have opened"); + var $backdrop = $('.modal-backdrop'); + assert.strictEqual($backdrop.length, 1, "the dialog should have a modal backdrop"); + testUtils.dom.click('.modal.show'); // Click on backdrop is in fact a direct click on the .modal element + assert.strictEqual($('.modal.show').length, 1, "the dialog should still be opened"); + + dialog.close(); + }); }); });