diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 3088c60510..e4213b8fcd 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -106,7 +106,7 @@ {{end}} {{end}} - diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index fb5b3b191d..a754e2ae9a 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -1,12 +1,12 @@ import $ from 'jquery'; 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 {setFileFolding} from './file-fold.js'; import {getComboMarkdownEditor, initComboMarkdownEditor} from './comp/ComboMarkdownEditor.js'; import {toAbsoluteUrl} from '../utils.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'; const {appSubUrl} = window.config; @@ -673,19 +673,24 @@ export function initRepoIssueBranchSelect() { }); } -export function initSingleCommentEditor($commentForm) { +export async function initSingleCommentEditor($commentForm) { // pages: - // * normal new issue/pr page, no status-button - // * issue/pr view page, with comment form, has 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 and comment-button const opts = {}; const statusButton = document.querySelector('#status-button'); - if (statusButton) { - opts.onContentChanged = (editor) => { - const statusText = statusButton.getAttribute(editor.value().trim() ? 'data-status-and-comment' : 'data-status'); - statusButton.textContent = statusText; - }; - } - initComboMarkdownEditor($commentForm.find('.combo-markdown-editor'), opts); + const commentButton = document.querySelector('#comment-button'); + opts.onContentChanged = (editor) => { + const editorText = editor.value().trim(); + if (statusButton) { + statusButton.textContent = statusButton.getAttribute(editorText ? 'data-status-and-comment' : 'data-status'); + } + 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) {