Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Quote Reply button on review diff #13830

Merged
merged 3 commits into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,25 +901,23 @@ async function initRepository() {
const target = $(this).data('target');
const quote = $(`#comment-${target}`).text().replace(/\n/g, '\n> ');
const content = `> ${quote}\n\n`;

let $content;
let $simplemde = autoSimpleMDE;
if ($(this).hasClass('quote-reply-diff')) {
const $parent = $(this).closest('.comment-code-cloud');
$parent.find('button.comment-form-reply').trigger('click');
$content = $parent.find('[name="content"]');
if ($content.val() !== '') {
$content.val(`${$content.val()}\n\n${content}`);
} else {
$content.val(`${content}`);
}
$content.focus();
} else if (autoSimpleMDE !== null) {
if (autoSimpleMDE.value() !== '') {
autoSimpleMDE.value(`${autoSimpleMDE.value()}\n\n${content}`);
$simplemde = $parent.find('[name="content"]').data('simplemde');
}
if ($simplemde !== null) {
if ($simplemde.value() !== '') {
$simplemde.value(`${$simplemde.value()}\n\n${content}`);
} else {
autoSimpleMDE.value(`${content}`);
$simplemde.value(`${content}`);
}
}
requestAnimationFrame(() => {
$simplemde.codemirror.focus();
$simplemde.codemirror.setCursor($simplemde.codemirror.lineCount(), 0);
});
event.preventDefault();
});

Expand Down Expand Up @@ -1082,8 +1080,10 @@ async function initRepository() {
$textarea.val($rawContent.text());
$simplemde.value($rawContent.text());
}
$textarea.focus();
$simplemde.codemirror.focus();
requestAnimationFrame(() => {
$textarea.focus();
$simplemde.codemirror.focus();
});
event.preventDefault();
});

Expand Down