mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-04 08:17:24 -05:00
Disable issue/PR comment button given empty input (#31463)
Given an empty issue/PR comment, the comment history would not be updated if the user were to submit it. Therefore, it would make since to just disable the comment button when the text editor is empty. This is inline with what GitHub does when given empty text editor input. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
f4921b9daa
commit
0c4ff01109
@ -106,7 +106,7 @@
|
|||||||
</button>
|
</button>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
<button class="ui primary button">
|
<button id="comment-button" class="ui primary button">
|
||||||
{{ctx.Locale.Tr "repo.issues.create_comment"}}
|
{{ctx.Locale.Tr "repo.issues.create_comment"}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import {htmlEscape} from 'escape-goat';
|
import {htmlEscape} from 'escape-goat';
|
||||||
import {showTemporaryTooltip, createTippy} from '../modules/tippy.js';
|
import {createTippy, showTemporaryTooltip} from '../modules/tippy.js';
|
||||||
import {hideElem, showElem, toggleElem} from '../utils/dom.js';
|
import {hideElem, showElem, toggleElem} from '../utils/dom.js';
|
||||||
import {setFileFolding} from './file-fold.js';
|
import {setFileFolding} from './file-fold.js';
|
||||||
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
|
import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js';
|
||||||
import {toAbsoluteUrl} from '../utils.js';
|
import {toAbsoluteUrl} from '../utils.js';
|
||||||
import {initDropzone} from './dropzone.js';
|
import {initDropzone} from './dropzone.js';
|
||||||
import {POST, GET} from '../modules/fetch.js';
|
import {GET, POST} from '../modules/fetch.js';
|
||||||
import {showErrorToast} from '../modules/toast.js';
|
import {showErrorToast} from '../modules/toast.js';
|
||||||
|
|
||||||
const {appSubUrl} = window.config;
|
const {appSubUrl} = window.config;
|
||||||
@ -673,19 +673,24 @@ export function initRepoIssueBranchSelect() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initSingleCommentEditor($commentForm) {
|
export async function initSingleCommentEditor($commentForm) {
|
||||||
// pages:
|
// pages:
|
||||||
// * normal new issue/pr page, no status-button
|
// * normal new issue/pr page: no status-button, no comment-button (there is only a normal submit button which can submit empty content)
|
||||||
// * issue/pr view page, with comment form, has status-button
|
// * issue/pr view page: with comment form, has status-button and comment-button
|
||||||
const opts = {};
|
const opts = {};
|
||||||
const statusButton = document.querySelector('#status-button');
|
const statusButton = document.querySelector('#status-button');
|
||||||
if (statusButton) {
|
const commentButton = document.querySelector('#comment-button');
|
||||||
opts.onContentChanged = (editor) => {
|
opts.onContentChanged = (editor) => {
|
||||||
const statusText = statusButton.getAttribute(editor.value().trim() ? 'data-status-and-comment' : 'data-status');
|
const editorText = editor.value().trim();
|
||||||
statusButton.textContent = statusText;
|
if (statusButton) {
|
||||||
};
|
statusButton.textContent = statusButton.getAttribute(editorText ? 'data-status-and-comment' : 'data-status');
|
||||||
}
|
}
|
||||||
initComboMarkdownEditor($commentForm.find('.combo-markdown-editor'), opts);
|
if (commentButton) {
|
||||||
|
commentButton.disabled = !editorText;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const editor = await initComboMarkdownEditor($commentForm.find('.combo-markdown-editor'), opts);
|
||||||
|
opts.onContentChanged(editor); // sync state of buttons with the initial content
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initIssueTemplateCommentEditors($commentForm) {
|
export function initIssueTemplateCommentEditors($commentForm) {
|
||||||
|
Loading…
Reference in New Issue
Block a user