Skip to content

Commit e078d08

Browse files
zeripath6543
andauthored
Fix close button change on delete in simplemde area (go-gitea#15737) (go-gitea#15747)
Backport go-gitea#15737 * Fix close button change on delete in simplemde area Fix issue with close button changing when deleting in the simplemde textarea. Signed-off-by: Andrew Thornton <[email protected]> * apply suggestion Co-authored-by: 6543 <[email protected]> Co-authored-by: 6543 <[email protected]>
1 parent a83fb3a commit e078d08

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

web_src/js/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,11 +1157,9 @@ async function initRepository() {
11571157
// Change status
11581158
const $statusButton = $('#status-button');
11591159
$('#comment-form textarea').on('keyup', function () {
1160-
if ($(this).val().length === 0) {
1161-
$statusButton.text($statusButton.data('status'));
1162-
} else {
1163-
$statusButton.text($statusButton.data('status-and-comment'));
1164-
}
1160+
const $simplemde = $(this).data('simplemde');
1161+
const value = ($simplemde && $simplemde.value()) ? $simplemde.value() : $(this).val();
1162+
$statusButton.text($statusButton.data(value.length === 0 ? 'status' : 'status-and-comment'));
11651163
});
11661164
$statusButton.on('click', () => {
11671165
$('#status').val($statusButton.data('status-val'));
@@ -1670,6 +1668,8 @@ function setCommentSimpleMDE($editArea) {
16701668
}
16711669
});
16721670
attachTribute(simplemde.codemirror.getInputField(), {mentions: true, emoji: true});
1671+
$editArea.data('simplemde', simplemde);
1672+
$(simplemde.codemirror.getInputField()).data('simplemde', simplemde);
16731673
return simplemde;
16741674
}
16751675

0 commit comments

Comments
 (0)