From b7568b8ce264fc80ee74a6557c7baff3ee32fa65 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 24 Jul 2017 13:37:04 +0200 Subject: [PATCH] Fixed issue #1291 - Block escape key when creating / editing text modules. --- .../app/lib/base/jquery.contenteditable.js | 3 +++ .../app/lib/base/jquery.textmodule.js | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js index 195c33e08..a9fd43626 100644 --- a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js +++ b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js @@ -581,6 +581,9 @@ // get correct val if textbox $.fn.ceg = function() { var plugin = $.data(this[0], 'plugin_' + pluginName) + if (!plugin) { + return + } return plugin.value() } diff --git a/app/assets/javascripts/app/lib/base/jquery.textmodule.js b/app/assets/javascripts/app/lib/base/jquery.textmodule.js index f294a115e..0b0e30117 100644 --- a/app/assets/javascripts/app/lib/base/jquery.textmodule.js +++ b/app/assets/javascripts/app/lib/base/jquery.textmodule.js @@ -43,14 +43,17 @@ this.$element.on('keydown', function (e) { - // esc - if (e.keyCode === 27) { - _this.close() - } - // navigate through item if (_this.isActive()) { + // esc + if (e.keyCode === 27) { + e.preventDefault() + e.stopPropagation() + _this.close() + return + } + // enter if (e.keyCode === 13) { e.preventDefault() @@ -106,7 +109,11 @@ menu.scrollTop( menu.scrollTop() + invisibleHeight ) } } + } + // esc + if (e.keyCode === 27) { + _this.close() } })