From 755ef9b1005a2f881700b7587b2b707112793ff9 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 7 Dec 2020 18:16:08 +0100 Subject: [PATCH] Improved the iOS WebKit click detection inside the editor margin --- .../3rdParty/redactor2/plugins/WoltLabCaret.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js index 24fe65fabe..ad68c7eebd 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js @@ -482,14 +482,18 @@ $.Redactor.prototype.WoltLabCaret = function() { _handleEditorClick: function (event) { var clientY = event.clientY; + + // Treat this as a collapsed selection instead, because the iOS Safari + // breaks event delegation and refuses to trigger click-style events + // for non-link/non-input elements. Thanks Apple. + var isIosTouch = _iOS && _touchstartTarget === event.target && this.utils.isBlockTag(_touchstartTarget.nodeName); + + if (clientY === undefined && isIosTouch) { + clientY = event.changedTouches[0].clientY; + } + if (!this.selection.get().isCollapsed) { - if (_isSafari && _iOS && _touchstartTarget === event.target && this.utils.isBlockTag(_touchstartTarget.nodeName)) { - // Treat this as a collapsed selection instead, because the iOS Safari - // breaks event delegation and refuses to trigger click-style events - // for non-link/non-input elements. Thanks Apple. - clientY = event.changedTouches[0].clientY; - } - else { + if (!isIosTouch || clientY === undefined) { // ignore text selection return; } -- 2.20.1