From f868957b0dca3047c09fc646cde7a2264f0e931f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 20 Sep 2021 18:25:10 +0200 Subject: [PATCH] Skip bogus selection changes --- .../files/js/3rdParty/redactor2/plugins/WoltLabCaret.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- 2.20.1