From c4bf1bd17f5337341b4ab1235f7bc034a3f2e84b Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Sun, 12 Oct 2014 23:11:33 +0000 Subject: [PATCH] Quicktags: move focusing the editor after inserting content to the end of the code blocks. Fixes a bug in Chrome where both the textarea and the window may auto-scroll to unexpected position on clicking a Quicktags button. Part props avryl, fixes #29944 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@29884 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/quicktags.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/js/quicktags.js b/src/wp-includes/js/quicktags.js index 314a0d2113..026c2b28f4 100644 --- a/src/wp-includes/js/quicktags.js +++ b/src/wp-includes/js/quicktags.js @@ -384,10 +384,10 @@ function edButton(id, display, tagStart, tagEnd, access) { canvas.value = text.substring(0, startPos) + content + text.substring(endPos, text.length); - canvas.focus(); canvas.selectionStart = startPos + content.length; canvas.selectionEnd = startPos + content.length; canvas.scrollTop = scrollTop; + canvas.focus(); } else { canvas.value += content; canvas.focus(); @@ -510,10 +510,10 @@ function edButton(id, display, tagStart, tagEnd, access) { } } - canvas.focus(); canvas.selectionStart = cursorPos; canvas.selectionEnd = cursorPos; canvas.scrollTop = scrollTop; + canvas.focus(); } else { // other browsers? if ( !endTag ) { canvas.value += t.tagStart;