Consistent editor focus/scrolling into view for comments
authorAlexander Ebert <ebert@woltlab.com>
Thu, 8 Mar 2018 11:27:40 +0000 (12:27 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 8 Mar 2018 11:27:40 +0000 (12:27 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Comment/Add.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Comment/Response/Add.js

index 60e2928311850272337bbe9b1ce02aced76d51a7..e4c07e29e57b610b0e00063f352f3c8e527628ad 100644 (file)
@@ -64,9 +64,7 @@ function(
                                        
                                        this._content.classList.remove('collapsed');
                                        
-                                       UiScroll.element(this._container, (function () {
-                                               window.jQuery(this._textarea).redactor('WoltLabCaret.endOfEditor');
-                                       }).bind(this));
+                                       this._focusEditor();
                                }
                        }).bind(this));
                        
@@ -75,6 +73,17 @@ function(
                        submitButton.addEventListener(WCF_CLICK_EVENT, this._submit.bind(this));
                },
                
+               /**
+                * Scrolls the editor into view and sets the caret to the end of the editor.
+                * 
+                * @protected
+                */
+               _focusEditor: function () {
+                       UiScroll.element(this._container, (function () {
+                               window.jQuery(this._textarea).redactor('WoltLabCaret.endOfEditor');
+                       }).bind(this));
+               },
+               
                /**
                 * Submits the guest dialog.
                 * 
index fdcd1db793d9e8ed3f5bf29ca247d62594f6a036..628348475f5ce74959322318e33ed671f10ba148 100644 (file)
@@ -82,6 +82,9 @@ function(
                        // the error message can appear anywhere in the container, not exclusively after the textarea
                        var innerError = elBySel('.innerError', this._textarea.parentNode);
                        if (innerError !== null) elRemove(innerError);
+                       
+                       this._content.classList.remove('collapsed');
+                       this._focusEditor();
                },
                
                _getParameters: function () {