Skip to content

Commit b99bef0

Browse files
wxiaoguangyardenshoham
authored andcommitted
Change button text for commenting and closing an issue at the same time (go-gitea#23135)
Close go-gitea#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 35a3b45 commit b99bef0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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,

web_src/js/features/repo-legacy.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,18 @@ export function initRepoCommentForm() {
6868
}
6969

7070
(async () => {
71+
const $statusButton = $('#status-button');
7172
for (const textarea of $commentForm.find('textarea:not(.review-textarea, .no-easymde)')) {
7273
// Don't initialize EasyMDE for the dormant #edit-content-form
7374
if (textarea.closest('#edit-content-form')) {
7475
continue;
7576
}
76-
const easyMDE = await createCommentEasyMDE(textarea);
77+
const easyMDE = await createCommentEasyMDE(textarea, {
78+
'onChange': () => {
79+
const value = easyMDE?.value().trim();
80+
$statusButton.text($statusButton.attr(value.length === 0 ? 'data-status' : 'data-status-and-comment'));
81+
},
82+
});
7783
initEasyMDEImagePaste(easyMDE, $commentForm.find('.dropzone'));
7884
}
7985
})();

0 commit comments

Comments
 (0)