From 257c0902f47fba36bc1a0978adbffeed23ce301f Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Fri, 30 May 2025 17:35:25 +0200 Subject: [PATCH] Patch for cards missing description The problem was that after redirecting back with morphing, the autosave mechanism would trigger an autosave call with an empty content. This is a first patch. The editor shouldn't be triggering these "change" events in the first place when loading the editor. --- app/javascript/controllers/auto_save_controller.js | 4 ++++ app/views/cards/container/_title.html.erb | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/javascript/controllers/auto_save_controller.js b/app/javascript/controllers/auto_save_controller.js index 0323ab9ad..a99c08192 100644 --- a/app/javascript/controllers/auto_save_controller.js +++ b/app/javascript/controllers/auto_save_controller.js @@ -26,6 +26,10 @@ export default class extends Controller { } } + reset() { + this.#timer = null + } + // Private #scheduleSave() { diff --git a/app/views/cards/container/_title.html.erb b/app/views/cards/container/_title.html.erb index 1767fd854..673814b74 100644 --- a/app/views/cards/container/_title.html.erb +++ b/app/views/cards/container/_title.html.erb @@ -10,7 +10,8 @@ <% end %> <% else %> - <%= form_with model: card, url: collection_card_path(card.collection, card), id: "card_form", class: "card__content", data: { controller: "autoresize auto-save" } do |form| %> + <%= form_with model: card, url: collection_card_path(card.collection, card), id: "card_form", class: "card__content", data: { + controller: "autoresize auto-save", action: "turbo:morph@window->auto-save#reset" } do |form| %>

<%= form.text_area :title, placeholder: "Name it…", class: "input input--textarea full-width borderless txt-align-start autoresize__textarea",