From 495dc7a5ef034fa0887fe78c63a94c627a10c92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 15 Mar 2019 11:18:14 +0100 Subject: [PATCH] Connect only once wizard dialog to keydown update is called on each state so it binds multiple times to keydown and call multiple times response with end state. This results in trying to delete multiple times the same wizard session which fails. issue8179 review60591002 --- src/wizard.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wizard.js b/src/wizard.js index 4c9c1ec282..7189a3d595 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -235,6 +235,14 @@ this.dialog = dialog.modal; this.content = dialog.content; this.footer = dialog.footer; + this.dialog.on('keydown', function(e) { + if (e.which == Sao.common.ESC_KEYCODE) { + e.preventDefault(); + if (this.end_state in this.states) { + this.response(this.end_state); + } + } + }.bind(this)); dialog.body.append(this.widget).append(this.info_bar.el); }, clean: function() { @@ -262,14 +270,6 @@ update: function(view, buttons) { this.content.unbind('submit'); Sao.Wizard.Dialog._super.update.call(this, view, buttons); - this.dialog.on('keydown', function(e) { - if (e.which == Sao.common.ESC_KEYCODE) { - e.preventDefault(); - if (this.end_state in this.states) { - this.response(this.end_state); - } - } - }.bind(this)); this.show(); }, destroy: function(action) {