From: Alexander Ebert Date: Mon, 20 Sep 2021 16:25:10 +0000 (+0200) Subject: Skip bogus selection changes X-Git-Tag: 5.4.8_dev_1~13 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f868957b0dca3047c09fc646cde7a2264f0e931f;p=GitHub%2FWoltLab%2FWCF.git Skip bogus selection changes --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js index 61130a3b05..4d2f5a6c58 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js @@ -619,6 +619,14 @@ $.Redactor.prototype.WoltLabCaret = function() { var anchorNode, sibling; var selection = window.getSelection(); + if (!selection.rangeCount) { + // Skip invocations that do not have an active range. This happens if the + // user loads a page but has not yet interacted with the page. Such a + // selection is the result of a synthetic event without any prior user + // interaction. + return; + } + if (!selection.isCollapsed) { if (_isSafari && _iOS && _touchstartTarget === event.target && this.utils.isBlockTag(_touchstartTarget.nodeName)) { // Treat this as a collapsed selection instead, because the iOS Safari