From 7164e4b4c8f1a64cd9e558ca9fa41d35c714eb6b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 18 Oct 2020 06:39:21 +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. Fixes #51175. git-svn-id: https://develop.svn.wordpress.org/trunk@49187 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/lib/comment-reply.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/js/_enqueues/lib/comment-reply.js b/src/js/_enqueues/lib/comment-reply.js index 9e4b77d31d..5d20672058 100644 --- a/src/js/_enqueues/lib/comment-reply.js +++ b/src/js/_enqueues/lib/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; }