Fixed editor not receiving focus after custom button click
authorAlexander Ebert <ebert@woltlab.com>
Thu, 1 Sep 2016 09:28:06 +0000 (11:28 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 1 Sep 2016 09:28:13 +0000 (11:28 +0200)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabButton.js

index c5cd1ed40002c1cdfd94c8ca5ef9f3a05dd4ccc3..e2c9ef80ad74c234e5808b683c76c57670248c39 100644 (file)
@@ -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);
                }
        };
 };