diff --git a/web_src/js/features/comp/EasyMDE.js b/web_src/js/features/comp/EasyMDE.js index 182e6b429df4e..2979627b0096a 100644 --- a/web_src/js/features/comp/EasyMDE.js +++ b/web_src/js/features/comp/EasyMDE.js @@ -77,6 +77,9 @@ export async function createCommentEasyMDE(textarea, easyMDEOptions = {}) { const inputField = easyMDE.codemirror.getInputField(); + easyMDE.codemirror.on('change', (...args) => { + easyMDEOptions?.onChange?.(...args); + }); easyMDE.codemirror.setOption('extraKeys', { 'Cmd-Enter': codeMirrorQuickSubmit, 'Ctrl-Enter': codeMirrorQuickSubmit, diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js index a9229c0d1e6f5..118475e32e2cf 100644 --- a/web_src/js/features/repo-legacy.js +++ b/web_src/js/features/repo-legacy.js @@ -85,12 +85,18 @@ export function initRepoCommentForm() { } (async () => { + const $statusButton = $('#status-button'); for (const textarea of $commentForm.find('textarea:not(.review-textarea, .no-easymde)')) { // Don't initialize EasyMDE for the dormant #edit-content-form if (textarea.closest('#edit-content-form')) { continue; } - const easyMDE = await createCommentEasyMDE(textarea); + const easyMDE = await createCommentEasyMDE(textarea, { + 'onChange': () => { + const value = easyMDE?.value().trim(); + $statusButton.text($statusButton.attr(value.length === 0 ? 'data-status' : 'data-status-and-comment')); + }, + }); initEasyMDEImagePaste(easyMDE, $commentForm.find('.dropzone')); } })();