Ignore click events that were triggered outside of the editor
authorAlexander Ebert <ebert@woltlab.com>
Mon, 26 Jul 2021 15:23:41 +0000 (17:23 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 26 Jul 2021 15:23:41 +0000 (17:23 +0200)
This appears to haben if the click event was partially intercepted because of an open overlay that was implicitly closed.

wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js

index 5573c0adc57dfa61fdf17b7d2c9691da67d1105b..851735361aa782eadbf500501ca9732e670d4a54 100644 (file)
@@ -481,6 +481,15 @@ $.Redactor.prototype.WoltLabCaret = function() {
                },
                
                _handleEditorClick: function (event) {
+                       var selection = this.selection.get();
+                       if (
+                               selection.anchorNode
+                               && !this.core.editor()[0].contains(selection.anchorNode)
+                       ) {
+                               // The focus is still outstide of the editor, do nothing here.
+                               return;
+                       }
+
                        var clientY = event.clientY;
 
                        // Treat this as a collapsed selection instead, because the iOS Safari