From: Alexander Ebert Date: Mon, 20 Jan 2020 12:36:42 +0000 (+0100) Subject: Selected text hidden in an element's overflow should not trigger the quote tooltip X-Git-Tag: 5.2.2~45 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1bd8975de92eef0dc41a649adeb33fa3dffd5237;p=GitHub%2FWoltLab%2FWCF.git Selected text hidden in an element's overflow should not trigger the quote tooltip --- diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index d94279d331..61b641d262 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -1096,6 +1096,23 @@ if (COMPILER_TARGET_DEFAULT) { var startContainer = elClosest(range.startContainer, '.jsQuoteMessageContainer'); var endContainer = elClosest(range.endContainer, '.jsQuoteMessageContainer'); if (startContainer && startContainer === endContainer && !startContainer.classList.contains('jsInvalidQuoteTarget')) { + // Check if the selection is visible, such as text marked inside containers with an + // active overflow handling attached to it. This can be a side effect of the browser + // search which modifies the text selection, but cannot be distinguished from manual + // selections initiated by the user. + var commonAncestor = range.commonAncestorContainer; + if (commonAncestor.nodeType !== Node.ELEMENT_NODE) { + commonAncestor = commonAncestor.parentNode; + } + + var offsetParent = commonAncestor.offsetParent; + if (startContainer.contains(offsetParent)) { + if (offsetParent.scrollTop + offsetParent.clientHeight < commonAncestor.offsetTop) { + // The selected text is not visible to the user. + return; + } + } + this._activeContainerID = startContainer.id; } }