From: Alexander Ebert Date: Mon, 7 Dec 2020 17:16:08 +0000 (+0100) Subject: Improved the iOS WebKit click detection inside the editor margin X-Git-Tag: 5.3.2~54 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=755ef9b1005a2f881700b7587b2b707112793ff9;p=GitHub%2FWoltLab%2FWCF.git Improved the iOS WebKit click detection inside the editor margin --- 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; }