From d3ec7bf2d09b8bb7b1aa6cc9b26a7e6fc7ac1161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 13 Jan 2020 23:51:27 +0100 Subject: [PATCH] Manage escape key on UniqueDialog On escape key pressed, we call close method and reject the promise like a cancel. issue8947 review266611002 --- src/common.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common.js b/src/common.js index 8a1d7f4bb8..04cbf723b4 100644 --- a/src/common.js +++ b/src/common.js @@ -2852,7 +2852,7 @@ this.running = false; }, build_dialog: function() { - var dialog = new Sao.Dialog('', this.class_); + var dialog = new Sao.Dialog('', this.class_, undefined, false); return dialog; }, run: function() { @@ -2873,6 +2873,12 @@ dialog.modal.find('input,select') .filter(':visible').first().focus(); }); + dialog.modal.on('keydown', function(e) { + if (e.which == Sao.common.ESC_KEYCODE) { + this.close(dialog); + prm.reject(); + } + }.bind(this)); return prm; }, close: function(dialog) {