Fixed clicking on a suggestion
authorAlexander Ebert <ebert@woltlab.com>
Wed, 26 Mar 2014 13:45:12 +0000 (14:45 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 26 Mar 2014 13:45:12 +0000 (14:45 +0100)
wcfsetup/install/files/js/WCF.Message.js

index 67c4dd1081c3dee7bc01385436108e7f20e38c24..03f15d3d5681b8ad7b3f18aa6480b6e8781fa6d4 100644 (file)
@@ -2954,6 +2954,12 @@ WCF.Message.Share.Page = Class.extend({
  * is initialized!
  */
 WCF.Message.UserMention = Class.extend({
+       /**
+        * current caret position
+        * @var DOMRange
+        */
+       _caretPosition: null,
+       
        /**
         * name of the class used to get the user suggestions
         * @var string
@@ -2990,6 +2996,10 @@ WCF.Message.UserMention = Class.extend({
         */
        _mentionStart: '',
        
+       /**
+        * redactor instance object
+        * @var $.Redactor
+        */
        _redactor: null,
        
        /**
@@ -3028,6 +3038,9 @@ WCF.Message.UserMention = Class.extend({
         * @param       object          event
         */
        _click: function(event) {
+               // restore caret position
+               this._redactor.replaceRangesWith(this._caretPosition);
+               
                this._setUsername($(event.currentTarget).data('username'));
        },
        
@@ -3075,6 +3088,7 @@ WCF.Message.UserMention = Class.extend({
                
                // restore caret position
                this._redactor.replaceRangesWith($orgRange);
+               this._caretPosition = $orgRange;
                
                return $offsets;
        },