diff --git a/app/controllers/cards_controller.rb b/app/controllers/cards_controller.rb
index a8762a9cb..cb40079e8 100644
--- a/app/controllers/cards_controller.rb
+++ b/app/controllers/cards_controller.rb
@@ -22,7 +22,6 @@ class CardsController < ApplicationController
def update
@card.update! card_params
- redirect_to @card
end
def destroy
diff --git a/app/views/cards/_container.html.erb b/app/views/cards/_container.html.erb
index 821211be9..983f359ed 100644
--- a/app/views/cards/_container.html.erb
+++ b/app/views/cards/_container.html.erb
@@ -14,7 +14,7 @@
- <%= render "cards/container/title", card: card %>
+ <%= render "cards/container/content", card: card %>
<%= render "cards/display/perma/steps", card: card %>
diff --git a/app/views/cards/container/_closure.html.erb b/app/views/cards/container/_closure.html.erb
index 8784e43cf..6fa2fed57 100644
--- a/app/views/cards/container/_closure.html.erb
+++ b/app/views/cards/container/_closure.html.erb
@@ -7,21 +7,7 @@
<% end %>
<% else %>
-
- <%= link_to edit_card_path(card), class: "btn btn--circle-mobile borderless", data: { controller: "hotkey", action: "keydown.e@document->hotkey#click", turbo_frame: dom_id(card, :edit) } do %>
- <%= icon_tag "pencil", class: "icon--mobile-only" %>
- Edit
- e
- <% end %>
-
- <%= button_to card_closure_path(card), class: "btn btn--circle-mobile borderless",
- data: { controller: "hotkey", form_target: "submit", action: "keydown.d@document->hotkey#click" },
- form: { data: { controller: "form" } } do %>
- <%= icon_tag "check", class: "icon--mobile-only" %>
- Mark as Done
- d
- <% end %>
-
+ <%= render "cards/container/closure_buttons", card: card %>
<% if card.entropic? && card.open? && !card.postponed? %>
diff --git a/app/views/cards/container/_closure_buttons.html.erb b/app/views/cards/container/_closure_buttons.html.erb
new file mode 100644
index 000000000..3a82ace0a
--- /dev/null
+++ b/app/views/cards/container/_closure_buttons.html.erb
@@ -0,0 +1,15 @@
+
+ <%= link_to edit_card_path(card), class: "btn btn--circle-mobile borderless", data: { controller: "hotkey", action: "keydown.e@document->hotkey#click", turbo_frame: dom_id(card, :edit) } do %>
+ <%= icon_tag "pencil", class: "icon--mobile-only" %>
+ Edit
+ e
+ <% end %>
+
+ <%= button_to card_closure_path(card), class: "btn btn--circle-mobile borderless",
+ data: { controller: "hotkey", form_target: "submit", action: "keydown.d@document->hotkey#click" },
+ form: { data: { controller: "form" } } do %>
+ <%= icon_tag "check", class: "icon--mobile-only" %>
+ Mark as Done
+ d
+ <% end %>
+
diff --git a/app/views/cards/container/_title.html.erb b/app/views/cards/container/_content.html.erb
similarity index 79%
rename from app/views/cards/container/_title.html.erb
rename to app/views/cards/container/_content.html.erb
index 179659d71..ff0a6579f 100644
--- a/app/views/cards/container/_title.html.erb
+++ b/app/views/cards/container/_content.html.erb
@@ -1,15 +1,12 @@
<% if card.published? %>
<%= turbo_frame_tag card, :edit do %>
-
- <%= link_to card.title, edit_card_path(card), class: "card__title-link" %>
-
-
- <% unless card.description.blank? %>
-
- <%= card.description %>
-
+ <%# When canceling an edit (with the ESC key), restore the button area to show "Edit" instead of "Save changes". %>
+ <%= turbo_stream.update dom_id(card, :card_closure_toggle) do %>
+ <%= render "cards/container/closure_buttons", card: card %>
<% end %>
+
+ <%= render "cards/container/content_display", card: card %>
<% end %>
<% else %>
diff --git a/app/views/cards/container/_content_display.html.erb b/app/views/cards/container/_content_display.html.erb
new file mode 100644
index 000000000..3395c40bf
--- /dev/null
+++ b/app/views/cards/container/_content_display.html.erb
@@ -0,0 +1,9 @@
+
+ <%= link_to card.title, edit_card_path(card), class: "card__title-link" %>
+
+
+<% unless card.description.blank? %>
+
+ <%= card.description %>
+
+<% end %>
diff --git a/app/views/cards/container/_save_button.html.erb b/app/views/cards/container/_save_button.html.erb
new file mode 100644
index 000000000..feef2c027
--- /dev/null
+++ b/app/views/cards/container/_save_button.html.erb
@@ -0,0 +1,8 @@
+
+ <%= button_tag type: :submit, form: dom_id(card, :edit_form), class: "btn btn--circle-mobile borderless",
+ data: { controller: "hotkey", action: "keydown.ctrl+enter@document->hotkey#click keydown.meta+enter@document->hotkey#click" } do %>
+ <%= icon_tag "check", class: "icon--mobile-only" %>
+ Save changes
+ <%= hotkey_label(["ctrl", "enter"]) %>
+ <% end %>
+
diff --git a/app/views/cards/edit.html.erb b/app/views/cards/edit.html.erb
index 768fe133c..66f5c4cf2 100644
--- a/app/views/cards/edit.html.erb
+++ b/app/views/cards/edit.html.erb
@@ -1,5 +1,12 @@
<%= turbo_frame_tag @card, :edit do %>
- <%= form_with model: @card,
+ <%# When entering edit mode, this turbo-stream replaces the button area to show
+ "Save changes" instead of "Edit". Turbo processes this stream as part of the
+ frame response. %>
+ <%= turbo_stream.update dom_id(@card, :card_closure_toggle) do %>
+ <%= render "cards/container/save_button", card: @card %>
+ <% end %>
+
+ <%= form_with model: @card, id: dom_id(@card, :edit_form),
data: { controller: "autoresize form local-save", local_save_key_value: "card-#{@card.id}", action: "turbo:submit-end->local-save#submit" } do |form| %>
<%= form.label :title, class: "flex flex-column align-center autoresize__wrapper", data: { autoresize_target: "wrapper", autoresize_clone_value: "" } do %>
@@ -15,10 +22,6 @@
<%= general_prompts(@card.board) %>
<% end %>
- <%= form.button type: :submit, class: "btn btn--reversed fit-content txt-small", data: { form_target: "submit" } do %>
- Save changes
- <%= hotkey_label([ "ctrl", "enter" ]) %>
- <% end %>
<%= link_to "Close editor and discard changes", @card, data: { form_target: "cancel" }, hidden: true %>
<% end %>
<% end %>
diff --git a/app/views/cards/update.turbo_stream.erb b/app/views/cards/update.turbo_stream.erb
new file mode 100644
index 000000000..d5c35119c
--- /dev/null
+++ b/app/views/cards/update.turbo_stream.erb
@@ -0,0 +1,7 @@
+<%= turbo_stream.update dom_id(@card, :edit) do %>
+ <%= render "cards/container/content_display", card: @card %>
+<% end %>
+
+<%= turbo_stream.update dom_id(@card, :card_closure_toggle) do %>
+ <%= render "cards/container/closure_buttons", card: @card %>
+<% end %>
diff --git a/app/views/public/cards/show.html.erb b/app/views/public/cards/show.html.erb
index a0663416e..0fb1a8fc6 100644
--- a/app/views/public/cards/show.html.erb
+++ b/app/views/public/cards/show.html.erb
@@ -28,7 +28,7 @@
- <%= render "public/cards/show/title", card: @card %>
+ <%= render "public/cards/show/content", card: @card %>
<%= render "cards/display/public_preview/columns", card: @card if @card.open? %>
diff --git a/app/views/public/cards/show/_title.html.erb b/app/views/public/cards/show/_content.html.erb
similarity index 100%
rename from app/views/public/cards/show/_title.html.erb
rename to app/views/public/cards/show/_content.html.erb
diff --git a/test/controllers/cards_controller_test.rb b/test/controllers/cards_controller_test.rb
index ca60a714a..fd83eb577 100644
--- a/test/controllers/cards_controller_test.rb
+++ b/test/controllers/cards_controller_test.rb
@@ -46,13 +46,13 @@ class CardsControllerTest < ActionDispatch::IntegrationTest
end
test "update" do
- patch card_path(cards(:logo)), params: {
+ patch card_path(cards(:logo)), as: :turbo_stream, params: {
card: {
title: "Logo needs to change",
image: fixture_file_upload("moon.jpg", "image/jpeg"),
description: "Something more in-depth",
tag_ids: [ tags(:mobile).id ] } }
- assert_redirected_to card_path(cards(:logo))
+ assert_response :success
card = cards(:logo).reload
assert_equal "Logo needs to change", card.title