diff options
author | Luke Bennett <lukeeeebennettplus@gmail.com> | 2016-05-17 17:04:01 +0100 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2016-06-07 22:25:54 +0100 |
commit | ae736d81e1f64fe9439ac0675538d359cfdb5be9 (patch) | |
tree | 65909f34c584010dbf39ca4a2b1c6c3db2732153 | |
parent | fd248392dddcb484fbe21e3cee9d7a64f1e96960 (diff) | |
download | gitlab-ce-ae736d81e1f64fe9439ac0675538d359cfdb5be9.tar.gz |
Added a line to find the currently saved text and replace the markdown textarea text when cancelling
Updated CHANGELOG
Corrected the changes to store the markdown in a hidden input when edit starts and retrieve the original from that input when edit is cancelled
Replaced hidden input with form attribute
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/assets/javascripts/notes.js.coffee | 13 |
2 files changed, 9 insertions, 5 deletions
diff --git a/CHANGELOG b/CHANGELOG index b9189b80889..ff5a7c22e60 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -57,6 +57,7 @@ v 8.8.4 (unreleased) - Fix importer for GitHub comments on diff - Disable Webhooks before proceeding with the GitHub import - Added descriptions to notification settings dropdown + - Markdown editor now correctly resets the input value on edit cancellation !4175 v 8.8.3 - Fix 404 page when viewing TODOs that contain milestones or labels in different projects. !4312 diff --git a/app/assets/javascripts/notes.js.coffee b/app/assets/javascripts/notes.js.coffee index 8e33e915ba5..ad216910c8d 100644 --- a/app/assets/javascripts/notes.js.coffee +++ b/app/assets/javascripts/notes.js.coffee @@ -354,8 +354,7 @@ class @Notes Called in response to clicking the edit note link Replaces the note text with the note edit form - Adds a hidden div with the original content of the note to fill the edit note form with - if the user cancels + Adds a data attribute to the form with the original content of the note for cancellations ### showEditForm: (e, scrollTo, myLastNote) -> e.preventDefault() @@ -371,6 +370,8 @@ class @Notes done = ($noteText) -> # Neat little trick to put the cursor at the end noteTextVal = $noteText.val() + # Store the original note text in a data attribute to retrieve if a user cancels edit. + form.find('form.edit-note').data 'original-note', noteTextVal $noteText.val('').val(noteTextVal); new GLForm form @@ -393,14 +394,16 @@ class @Notes ### Called in response to clicking the edit note link - Hides edit form + Hides edit form and restores the original note text to the editor textarea. ### cancelEdit: (e) -> e.preventDefault() note = $(this).closest(".note") + form = note.find(".current-note-edit-form") note.removeClass "is-editting" - note.find(".current-note-edit-form") - .removeClass("current-note-edit-form") + form.removeClass("current-note-edit-form") + # Replace markdown textarea text with original note text. + form.find(".js-note-text").val(form.find('form.edit-note').data('original-note')) ### Called in response to deleting a note of any kind. |