aboutsummaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorJimmy Praet <jimmy.praet@ksz-bcss.fgov.be>2020-12-08 07:11:27 +0100
committerGitHub <noreply@github.com>2020-12-08 07:11:27 +0100
commit4d66ee1f74799196cbdbfd925c3f95e552584b42 (patch)
tree7dd71f148e75dcbf93bf4eb782fa915cf8d06592 /web_src
parent6bdcacd73b403354aa180bfada7236038d9712b1 (diff)
downloadgitea-4d66ee1f74799196cbdbfd925c3f95e552584b42.tar.gz
gitea-4d66ee1f74799196cbdbfd925c3f95e552584b42.zip
Fix Quote Reply button on review diff (#13830)
* Fix Quote Reply #13762 * requestAnimationFrame() instead of setTimeout() Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/index.js30
1 files changed, 15 insertions, 15 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index ef865529db..2cb928b203 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -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();
});
@@ -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();
});