aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-04-22 01:00:04 +0800
committerGitHub <noreply@github.com>2024-04-22 01:00:04 +0800
commitf95622cddc8db24719d10794e50ae6b125e6b96e (patch)
treeefee90209538f64a1b49139b150ae682f0b0a1b2 /web_src/js
parente865de1e9d65dc09797d165a51c8e705d2a86030 (diff)
downloadgitea-f95622cddc8db24719d10794e50ae6b125e6b96e.tar.gz
gitea-f95622cddc8db24719d10794e50ae6b125e6b96e.zip
Fix issue comment form and quick-submit (#30623)
1. Rewrite initGlobalEnterQuickSubmit (by the way, remove jQuery) 2. Fix issue comment form layout
Diffstat (limited to 'web_src/js')
-rw-r--r--web_src/js/features/common-global.js7
-rw-r--r--web_src/js/features/comp/QuickSubmit.js4
2 files changed, 4 insertions, 7 deletions
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index e7db9b2336..a821e1b921 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -46,10 +46,11 @@ export function initFootLanguageMenu() {
}
export function initGlobalEnterQuickSubmit() {
- $(document).on('keydown', '.js-quick-submit', (e) => {
- if (((e.ctrlKey && !e.altKey) || e.metaKey) && (e.key === 'Enter')) {
+ document.addEventListener('keydown', (e) => {
+ const isQuickSubmitEnter = ((e.ctrlKey && !e.altKey) || e.metaKey) && (e.key === 'Enter');
+ if (isQuickSubmitEnter && e.target.matches('textarea')) {
+ e.preventDefault();
handleGlobalEnterQuickSubmit(e.target);
- return false;
}
});
}
diff --git a/web_src/js/features/comp/QuickSubmit.js b/web_src/js/features/comp/QuickSubmit.js
index e6d7080bcf..477b3b9e2a 100644
--- a/web_src/js/features/comp/QuickSubmit.js
+++ b/web_src/js/features/comp/QuickSubmit.js
@@ -9,9 +9,5 @@ export function handleGlobalEnterQuickSubmit(target) {
// here use the event to trigger the submit event (instead of calling `submit()` method directly)
// otherwise the `areYouSure` handler won't be executed, then there will be an annoying "confirm to leave" dialog
form.dispatchEvent(new SubmitEvent('submit', {bubbles: true, cancelable: true}));
- } else {
- // if no form, then the editor is for an AJAX request, dispatch an event to the target, let the target's event handler to do the AJAX request.
- // the 'ce-' prefix means this is a CustomEvent
- target.dispatchEvent(new CustomEvent('ce-quick-submit', {bubbles: true}));
}
}