1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-23 02:38:35 +00:00

Fix issue comment form and quick-submit (#30623)

1. Rewrite initGlobalEnterQuickSubmit (by the way, remove jQuery)
2. Fix issue comment form layout
This commit is contained in:
wxiaoguang
2024-04-22 01:00:04 +08:00
committed by GitHub
parent e865de1e9d
commit f95622cddc
7 changed files with 37 additions and 38 deletions

View File

@@ -1080,8 +1080,8 @@ td .commit-summary {
clear: none;
}
.repository .comment.form .content .form::before,
.repository .comment.form .content .form::after {
.repository .comment.form .content .segment::before,
.repository .comment.form .content .segment::after {
right: 100%;
top: 20px;
border: solid transparent;
@@ -1092,13 +1092,13 @@ td .commit-summary {
pointer-events: none;
}
.repository .comment.form .content .form::before {
.repository .comment.form .content .segment::before {
border-right-color: var(--color-secondary);
border-width: 9px;
margin-top: -9px;
}
.repository .comment.form .content .form::after {
.repository .comment.form .content .segment::after {
border-right-color: var(--color-box-body);
border-width: 8px;
margin-top: -8px;

View File

@@ -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;
}
});
}

View File

@@ -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}));
}
}