From 75825f2de3a87d2119c406418acf4b686fad86d0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 6 Jun 2017 13:49:26 +0200 Subject: [PATCH] Fixed user suggestions inside Redactor --- wcfsetup/install/files/js/WCF.Message.js | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- 2.20.1