aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/repo-issue.js
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-03-02 17:36:21 -0500
committerGitHub <noreply@github.com>2023-03-02 16:36:21 -0600
commitef8209a953e7af14c1ee5c68678c2da959f511fb (patch)
tree0d7873d6e0b4f7cb0748c71449883cd928aa9c5f /web_src/js/features/repo-issue.js
parent9309098eab6446df0de625dfc2ec67936bdbb0f9 (diff)
downloadgitea-ef8209a953e7af14c1ee5c68678c2da959f511fb.tar.gz
gitea-ef8209a953e7af14c1ee5c68678c2da959f511fb.zip
Use async await to fix empty quote reply at first time (#23168) (#23256)
Backport #23168 The reason why quote reply is empty is when quote reply is clicked, it triggers the click function on `.comment-form-reply` button, and when the first time this function is triggered, easyMDE for the reply has not yet initialized, so that click handler of `.quote-reply` button in `repo-legacy.js` got an `undefined` as easyMDE, and the following lines which put quoted reply into the easyMDE is not executed. The workaround in this PR is to pass the replied content to '.comment-form-reply' button if easyMDE is not yet initialized (quote reply first clicked) and put the replied content into it the after easyMDE is created. Now quote reply on first click: https://user-images.githubusercontent.com/17645053/221452823-fc699d50-1649-4af1-952e-f04fc8d2978e.mov <br /> Update: The above change is not appropriate as stated in the [comment](https://github.com/go-gitea/gitea/pull/23168#issuecomment-1445562284) Use await instead Close #22075. Close #23247. Co-authored-by: HesterG <hestergong@gmail.com>
Diffstat (limited to 'web_src/js/features/repo-issue.js')
-rw-r--r--web_src/js/features/repo-issue.js30
1 files changed, 17 insertions, 13 deletions
diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js
index 4fc8bb5e62..4163fb120e 100644
--- a/web_src/js/features/repo-issue.js
+++ b/web_src/js/features/repo-issue.js
@@ -418,6 +418,22 @@ function assignMenuAttributes(menu) {
return id;
}
+export async function handleReply($el) {
+ hideElem($el);
+ const form = $el.closest('.comment-code-cloud').find('.comment-form');
+ form.removeClass('gt-hidden');
+ const $textarea = form.find('textarea');
+ let easyMDE = getAttachedEasyMDE($textarea);
+ if (!easyMDE) {
+ await attachTribute($textarea.get(), {mentions: true, emoji: true});
+ easyMDE = await createCommentEasyMDE($textarea);
+ }
+ $textarea.focus();
+ easyMDE.codemirror.focus();
+ assignMenuAttributes(form.find('.menu'));
+ return easyMDE;
+}
+
export function initRepoPullRequestReview() {
if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) {
const commentDiv = $(window.location.hash);
@@ -455,19 +471,7 @@ export function initRepoPullRequestReview() {
$(document).on('click', 'button.comment-form-reply', async function (e) {
e.preventDefault();
-
- hideElem($(this));
- const form = $(this).closest('.comment-code-cloud').find('.comment-form');
- form.removeClass('gt-hidden');
- const $textarea = form.find('textarea');
- let easyMDE = getAttachedEasyMDE($textarea);
- if (!easyMDE) {
- await attachTribute($textarea.get(), {mentions: true, emoji: true});
- easyMDE = await createCommentEasyMDE($textarea);
- }
- $textarea.focus();
- easyMDE.codemirror.focus();
- assignMenuAttributes(form.find('.menu'));
+ await handleReply($(this));
});
const $reviewBox = $('.review-box-panel');