From 3b95c8ac3771bb39ddb689f70b4773f3bacbc6d9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 11 2019 11:58:29 +0000 Subject: Fix previewing comment when there are two comment forms open If you open a form to add an inline comment in a PR, there are suddenly two #comment field. So if you go back to the main comment (not inline) and click on preview the content that gets previewed isn't from the correct form. With this commit, instead of accessing the first #comment we find in the DOM, we look for the parent .card and find the #comment there. Fixes https://pagure.io/pagure/issue/4315 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/repo_pull_request.html b/pagure/templates/repo_pull_request.html index 6c57da1..85505f8 100644 --- a/pagure/templates/repo_pull_request.html +++ b/pagure/templates/repo_pull_request.html @@ -1385,7 +1385,8 @@ $(document).ready(function () { var _el = $( "#initial_comment" ); var _token = "{{ form.csrf_token.current_token }}"; {% else %} - var _el = $( "#comment" ); + var _parent = $(event.target).closest('.card'); + var _el = $( _parent.find("#comment") ); var _token = "{{ mergeform.csrf_token.current_token }}"; {% endif %} @@ -1421,7 +1422,8 @@ $(document).ready(function () { var _el = $( "#initial_comment" ); var _token = "{{ form.csrf_token.current_token }}"; {% else %} - var _el = $( "#comment" ); + var _parent = $(event.target).closest('.card'); + var _el = $( _parent.find("#comment") ); var _token = "{{ mergeform.csrf_token.current_token }}"; {% endif %}