From a6c64bb69a33674a670783ac98f64c7df6939891 Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Wed, 27 May 2020 23:51:59 +0000 Subject: [PATCH] Fix embedded notes not being re-editable after note creation The issue is that the body of the embedded notes were being set to the value which tells the script not to read the original body after saving a note. This was a poor system prone to issues, so instead a DOM class is now explicitly added to the notes on note creation and cleared whenever a note gets saved. Additionally, the embedded note bodies were standardized to use the same initial value as non-embedded notes as well. --- app/javascript/src/javascripts/notes.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/javascript/src/javascripts/notes.js b/app/javascript/src/javascripts/notes.js index cdd7f2f17..385c6975d 100644 --- a/app/javascript/src/javascripts/notes.js +++ b/app/javascript/src/javascripts/notes.js @@ -602,7 +602,7 @@ let Note = { resize: "none", }); - if ($note_body.html() !== "Click to edit") { + if (!$note_body.hasClass("new-note")) { $textarea.val($note_body.data("original-body")); } @@ -680,6 +680,7 @@ let Note = { $note_box = Note.Box.find(data.html_id); $note_body.data("id", String(data.id)).attr("data-id", data.id); $note_box.data("id", String(data.id)).attr("data-id", data.id); + $note_box.removeClass("new-note"); $note_box.removeClass("unsaved"); $note_box.removeClass("movable"); } else { @@ -955,7 +956,7 @@ let Note = { Note.Box.scale($note_box); if (Note.embed) { Note.Body.display_text($note_box.children("div.note-box-inner-border"), sanitized_body); - Note.Body.display_text($note_body, "Click to edit."); + Note.Body.display_text($note_body, "Click to edit"); } else { Note.Body.display_text($note_body, sanitized_body); } @@ -971,6 +972,7 @@ let Note = { height: h }); Note.Box.update_data_attributes($note_box); + $note_box.addClass("new-note"); $note_box.addClass("unsaved"); $note_body.html("Click to edit"); $(".note-container").append($note_box);