r100398 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100397‎ | r100398 | r100399 >
Date:00:15, 21 October 2011
Author:brion
Status:ok
Tags:
Comment:
* (bug 31847) Fix positioning of WikiEditor 'header' insertions when selection is empty in IE 7/8

Follows up to the test cases added in r100391. jquery.textSelection's getCaretPosition() for IE needs to focus the textarea first in order to get consistent results when there's an empty selection -- getSelection() which returns the text already does this.

Because focus had previously been stolen by the drop-down menus in WikiEditor's toolbar, the saveCursorAndScrollTop() was getting a bogus result from getCaretPosition, saving that, then restoring the bad selection (wiping out the original caret position) right before going ahead with the encapsulateText call.

Now seems to get the correct caret position, and also doesn't appear to interfere with selections.
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/jquery/jquery.textSelection.js
@@ -208,12 +208,20 @@
209209 * Get the position (in resolution of bytes not nessecarily characters)
210210 * in a textarea
211211 *
 212+ * Will focus the textarea in some browsers (IE/Opera)
 213+ *
212214 * @fixme document the options parameters
213215 */
214216 getCaretPosition: function( options ) {
215217 function getCaret( e ) {
216218 var caretPos = 0, endPos = 0;
217219 if ( $.browser.msie ) {
 220+ // IE doesn't properly report non-selected caret position through
 221+ // the selection ranges when textarea isn't focused. This can
 222+ // lead to saving a bogus empty selection, which then screws up
 223+ // whatever we do later (bug 31847).
 224+ e.focus();
 225+
218226 // IE Support
219227 var preFinished = false;
220228 var periFinished = false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r1011261.18wmf1: MFT r98669, r99164, r99321, r99332, r99632, r99897, r99914, r99952,...catrope12:09, 28 October 2011
r101203REL1_18 MFT r99286, r99332, r100398, r100701, r101010reedy21:20, 28 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100391QUnit test cases for bug 31847: will trigger a fail on IE 6/7/8...brion22:50, 20 October 2011

Status & tagging log