From e078d08ecd080aa92aa389527d01623b96bed513 Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 6 May 2021 23:14:15 +0100 Subject: [PATCH] Fix close button change on delete in simplemde area (#15737) (#15747) Backport #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 * apply suggestion Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de> --- web_src/js/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web_src/js/index.js b/web_src/js/index.js index 5a21a095734e..dd1e192254b4 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1157,11 +1157,9 @@ async function initRepository() { // Change status const $statusButton = $('#status-button'); $('#comment-form textarea').on('keyup', function () { - if ($(this).val().length === 0) { - $statusButton.text($statusButton.data('status')); - } else { - $statusButton.text($statusButton.data('status-and-comment')); - } + const $simplemde = $(this).data('simplemde'); + const value = ($simplemde && $simplemde.value()) ? $simplemde.value() : $(this).val(); + $statusButton.text($statusButton.data(value.length === 0 ? 'status' : 'status-and-comment')); }); $statusButton.on('click', () => { $('#status').val($statusButton.data('status-val')); @@ -1670,6 +1668,8 @@ function setCommentSimpleMDE($editArea) { } }); attachTribute(simplemde.codemirror.getInputField(), {mentions: true, emoji: true}); + $editArea.data('simplemde', simplemde); + $(simplemde.codemirror.getInputField()).data('simplemde', simplemde); return simplemde; }