Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change button text for commenting and closing an issue at the same time #23135

Merged
merged 3 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions web_src/js/features/comp/EasyMDE.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion web_src/js/features/repo-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
})();
Expand Down