Skip to content

Commit bd2ba9f

Browse files
author
Earl Warren
committed
Merge pull request '[BUG] Fix Ctrl+Enter on submitting review comment' (go-gitea#2370) from gusted/forgejo-review-ctrlenter into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2370 Reviewed-by: Otto <[email protected]> Reviewed-by: Earl Warren <[email protected]>
2 parents 7bf93e5 + f04589d commit bd2ba9f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

web_src/js/features/repo-diff.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ function initRepoDiffConversationForm() {
5757
$form.addClass('is-loading');
5858
const formData = new FormData($form[0]);
5959

60-
// if the form is submitted by a button, append the button's name and value to the form data
61-
const submitter = submitEventSubmitter(e.originalEvent);
60+
// If the form is submitted by a button, append the button's name and value to the form data.
61+
// originalEvent can be undefined, such as an event that's caused by Ctrl+Enter, in that case
62+
// sent the event itself.
63+
const submitter = submitEventSubmitter(e.originalEvent ?? e);
6264
const isSubmittedByButton = (submitter?.nodeName === 'BUTTON') || (submitter?.nodeName === 'INPUT' && submitter.type === 'submit');
6365
if (isSubmittedByButton && submitter.name) {
6466
formData.append(submitter.name, submitter.value);
@@ -76,6 +78,7 @@ function initRepoDiffConversationForm() {
7678
$newConversationHolder.find('.dropdown').dropdown();
7779
initCompReactionSelector($newConversationHolder);
7880
} catch { // here the caught error might be a jQuery AJAX error (thrown by await $.post), which is not good to use for error message handling
81+
console.error('error when submitting conversation', e);
7982
showErrorToast(i18n.network_error);
8083
} finally {
8184
$form.removeClass('is-loading');

0 commit comments

Comments
 (0)