From b498108efaaff73c5dbfb69afec47b0909f44c2c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 1 Sep 2016 11:28:06 +0200 Subject: [PATCH] Fixed editor not receiving focus after custom button click --- .../redactor2/plugins/WoltLabButton.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabButton.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabButton.js index c5cd1ed400..e2c9ef80ad 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabButton.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabButton.js @@ -116,15 +116,19 @@ $.Redactor.prototype.WoltLabButton = function() { var data = { cancel: false }; WCF.System.Event.fireEvent('com.woltlab.wcf.redactor2', 'bbcode_' + bbcode + '_' + this.$element[0].id, data); - if (data.cancel === true) { - return; + if (data.cancel !== true) { + this.buffer.set(); + + var html = '[' + bbcode + ']' + this.selection.html() + (this.selection.is() ? '' : this.marker.html()) + '[/' + bbcode + ']'; + this.insert.html(html); + this.selection.restore(); } - this.buffer.set(); - - var html = '[' + bbcode + ']' + this.selection.html() + (this.selection.is() ? '' : this.marker.html()) + '[/' + bbcode + ']'; - this.insert.html(html); - this.selection.restore(); + window.setTimeout((function () { + if (document.activeElement !== this.$editor[0]) { + this.$editor[0].focus(); + } + }).bind(this), 10); } }; }; -- 2.20.1