Skip to content

Commit 658cbdd

Browse files
wxiaoguangGiteaBot
andauthored
Make submit event code work with both jQuery event and native event (#29223)
Partially related to #29200 and fix other potential bugs. Co-authored-by: Giteabot <teabot@gitea.io>
1 parent 5e1bf3e commit 658cbdd

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

web_src/js/features/common-issue-list.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function initCommonIssueListQuickGoto() {
4040
$form.on('submit', (e) => {
4141
// if there is no goto button, or the form is submitted by non-quick-goto elements, submit the form directly
4242
let doQuickGoto = !isElemHidden($goto);
43-
const submitter = submitEventSubmitter(e.originalEvent);
43+
const submitter = submitEventSubmitter(e);
4444
if (submitter !== $form[0] && submitter !== $input[0] && submitter !== $goto[0]) doQuickGoto = false;
4545
if (!doQuickGoto) return;
4646

web_src/js/features/repo-diff.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function initRepoDiffConversationForm() {
5858
const formData = new FormData($form[0]);
5959

6060
// 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);
61+
const submitter = submitEventSubmitter(e);
6262
const isSubmittedByButton = (submitter?.nodeName === 'BUTTON') || (submitter?.nodeName === 'INPUT' && submitter.type === 'submit');
6363
if (isSubmittedByButton && submitter.name) {
6464
formData.append(submitter.name, submitter.value);

web_src/js/utils/dom.js

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export function loadElem(el, src) {
211211
const needSubmitEventPolyfill = typeof SubmitEvent === 'undefined';
212212

213213
export function submitEventSubmitter(e) {
214+
e = e.originalEvent ?? e; // if the event is wrapped by jQuery, use "originalEvent", otherwise, use the event itself
214215
return needSubmitEventPolyfill ? (e.target._submitter || null) : e.submitter;
215216
}
216217

0 commit comments

Comments
 (0)