From: Alexander Ebert Date: Tue, 6 Jun 2017 11:49:26 +0000 (+0200) Subject: Fixed user suggestions inside Redactor X-Git-Tag: 2.1.16~12 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=75825f2de3a87d2119c406418acf4b686fad86d0;p=GitHub%2FWoltLab%2FWCF.git Fixed user suggestions inside Redactor --- diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index fd0cf76095..000745b9bb 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -3648,6 +3648,13 @@ WCF.Message.UserMention = Class.extend({ $startOffset = $startContainer.textContent.length - 1; } + // check if `$startContainer` is an element, as it causes `$startOffset` to be + // relative to the child nodes instead of the actual text length + if ($startContainer.nodeType === Node.ELEMENT_NODE && $startOffset > 0) { + $startContainer = $startContainer.childNodes[$startOffset - 1]; + $startOffset = $startContainer.textContent.length; + } + $startOffset -= (this._mentionStart.length + 1); // navigating with the keyboard before hitting enter will cause the text node to be split