From f7533ee85485fd2f6642dd96452e2a7f1a5859a6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 18 Oct 2020 17:11:06 +0000 Subject: [PATCH] Comments: Hide the link to the initial parent comment in the reply heading when replying to another comment. This ensures that the reply heading is updated correctly on single post URLs with the `?replytocom` query argument. Follow-up to [47506], [48876], [48904]. Props mailnew2ster, wpamitkumar, audrasjb, desrosj, SergeyBiryukov. Merges [49187] to the 5.5 branch. Fixes #51175. Built from https://develop.svn.wordpress.org/branches/5.5@49191 git-svn-id: http://core.svn.wordpress.org/branches/5.5@48953 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/comment-reply.js | 10 ++++++++++ wp-includes/js/comment-reply.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/wp-includes/js/comment-reply.js b/wp-includes/js/comment-reply.js index 698e894304..515ae2f957 100644 --- a/wp-includes/js/comment-reply.js +++ b/wp-includes/js/comment-reply.js @@ -178,8 +178,13 @@ window.addComment = ( function( window ) { var replyHeadingElement = getElementById( config.commentReplyTitleId ); var replyHeadingTextNode = replyHeadingElement && replyHeadingElement.firstChild; + var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling; if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE && headingText ) { + if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) { + replyLinkToParent.style.display = ''; + } + replyHeadingTextNode.textContent = headingText; } @@ -319,6 +324,7 @@ window.addComment = ( function( window ) { var replyHeading = getElementById( config.commentReplyTitleId ); var replyHeadingTextNode = replyHeading && replyHeading.firstChild; + var replyLinkToParent = replyHeadingTextNode && replyHeadingTextNode.nextSibling; if ( ! addBelowElement || ! respondElement || ! parentIdField ) { // Missing key elements, fail. @@ -342,6 +348,10 @@ window.addComment = ( function( window ) { addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling ); if ( replyHeadingTextNode && replyHeadingTextNode.nodeType === Node.TEXT_NODE ) { + if ( replyLinkToParent && 'A' === replyLinkToParent.nodeName && replyLinkToParent.id !== config.cancelReplyId ) { + replyLinkToParent.style.display = 'none'; + } + replyHeadingTextNode.textContent = replyTo; } diff --git a/wp-includes/js/comment-reply.min.js b/wp-includes/js/comment-reply.min.js index 8c5475821c..cb4c954e2c 100644 --- a/wp-includes/js/comment-reply.min.js +++ b/wp-includes/js/comment-reply.min.js @@ -1,2 +1,2 @@ /*! This file is auto-generated */ -window.addComment=function(p){var f,v,I,C=p.document,h={commentReplyClass:"comment-reply-link",commentReplyTitleId:"reply-title",cancelReplyId:"cancel-comment-reply-link",commentFormId:"commentform",temporaryFormId:"wp-temp-form-div",parentIdFieldId:"comment_parent",postIdFieldId:"comment_post_ID"},e=p.MutationObserver||p.WebKitMutationObserver||p.MozMutationObserver,i="querySelector"in C&&"addEventListener"in p,n=!!C.documentElement.dataset;function t(){r(),function(){if(!e)return;new e(o).observe(C.body,{childList:!0,subtree:!0})}()}function r(e){if(i&&(f=E(h.cancelReplyId),v=E(h.commentFormId),f)){f.addEventListener("touchstart",l),f.addEventListener("click",l);var t=function(e){if((e.metaKey||e.ctrlKey)&&13===e.keyCode)return v.removeEventListener("keydown",t),e.preventDefault(),v.submit.click(),!1};v&&v.addEventListener("keydown",t);for(var n,r=function(e){var t,n=h.commentReplyClass;e&&e.childNodes||(e=C);t=C.getElementsByClassName?e.getElementsByClassName(n):e.querySelectorAll("."+n);return t}(e),o=0,d=r.length;o