Skip to content

Commit 8b86ccb

Browse files
authored
Change button text for commenting and closing an issue at the same time (#23135)
Close #10468 Without SimpleMDE/EasyMDE, using Simple Textarea, the button text could be changed when content changes. After introducing SimpleMDE/EasyMDE, there is no code for updating the button text.
1 parent 725a97c commit 8b86ccb

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: web_src/js/features/comp/EasyMDE.js

+3
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ export async function createCommentEasyMDE(textarea, easyMDEOptions = {}) {
7777

7878
const inputField = easyMDE.codemirror.getInputField();
7979

80+
easyMDE.codemirror.on('change', (...args) => {
81+
easyMDEOptions?.onChange(...args);
82+
});
8083
easyMDE.codemirror.setOption('extraKeys', {
8184
'Cmd-Enter': codeMirrorQuickSubmit,
8285
'Ctrl-Enter': codeMirrorQuickSubmit,

Diff for: web_src/js/features/repo-legacy.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,18 @@ export function initRepoCommentForm() {
8585
}
8686

8787
(async () => {
88+
const $statusButton = $('#status-button');
8889
for (const textarea of $commentForm.find('textarea:not(.review-textarea, .no-easymde)')) {
8990
// Don't initialize EasyMDE for the dormant #edit-content-form
9091
if (textarea.closest('#edit-content-form')) {
9192
continue;
9293
}
93-
const easyMDE = await createCommentEasyMDE(textarea);
94+
const easyMDE = await createCommentEasyMDE(textarea, {
95+
'onChange': () => {
96+
const value = easyMDE?.value().trim();
97+
$statusButton.text($statusButton.attr(value.length === 0 ? 'data-status' : 'data-status-and-comment'));
98+
},
99+
});
94100
initEasyMDEImagePaste(easyMDE, $commentForm.find('.dropzone'));
95101
}
96102
})();

0 commit comments

Comments
 (0)