From 06bc7adb5e5daa152497efa2fec07334a0126398 Mon Sep 17 00:00:00 2001 From: Jakob L. Kreuze Date: Mon, 16 Feb 2026 12:50:24 -0500 Subject: Fix comment replies --- static/js/dynamic-comment-form.js | 51 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'static/js') diff --git a/static/js/dynamic-comment-form.js b/static/js/dynamic-comment-form.js index 809a755..75e2fb6 100644 --- a/static/js/dynamic-comment-form.js +++ b/static/js/dynamic-comment-form.js @@ -81,12 +81,55 @@ window.addEventListener("load", () => { }); window.addEventListener("load", () => { - // Unhide additional comment actions if Javascript is enabled. - let additionalActionsRows = document.querySelectorAll(".comment-additional-actions"); - for (let row of additionalActionsRows) { - row.removeAttribute("hidden"); + const replyToField = document.getElementById("reply-to"); + const commentFormModule = document.querySelector('.comment-form-module'); + + // Create a "Replying To" preview container dynamically + const previewContainer = document.createElement('div'); + previewContainer.id = 'reply-preview-area'; + previewContainer.style.display = 'none'; + commentFormModule.prepend(previewContainer); + + const replyButtons = document.querySelectorAll(".reply-button"); + for (const button of replyButtons) { + button.removeAttribute("hidden"); + button.addEventListener('click', (e) => { + replyTo.value = button.getAttribute("data-reply-to-id"); + const targetId = button.getAttribute('data-target'); + const originalComment = document.getElementById(targetId); + + if (originalComment) { + const clone = originalComment.cloneNode(true); + const nestedReplies = clone.querySelectorAll('.reply'); + nestedReplies.forEach(reply => reply.remove()); + const actionButtons = clone.querySelector('.comment-reactions'); + if (actionButtons) actionButtons.remove(); + previewContainer.innerHTML = ` +