Use morphing to replace the card and exclude turbo frames from being replaced

Reconnecting the frames result in a visible flickering.

This also prevents flickering in the avatars when replacing the card container.
This commit is contained in:
Jorge Manrubia
2025-04-21 09:24:57 +02:00
parent 48a6c05250
commit 3e1a2bcc7e
2 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -15,6 +15,6 @@ module CardScoped
end
def render_card_replacement
render turbo_stream: turbo_stream.replace([ @card, :card_container ], partial: "cards/container", locals: { card: @card.reload })
render turbo_stream: turbo_stream.replace([ @card, :card_container ], partial: "cards/container", method: :morph, locals: { card: @card.reload })
end
end
+2 -3
View File
@@ -32,10 +32,9 @@
</div>
<% if card.published? %>
<%# FIXME: Let's move this aside outside of the card container section so these frames don't reload/flicker when card is replaced %>
<aside class="card-perma__actions card-perma__actions--right" role="toolbar">
<%= turbo_frame_tag card, :watch, src: card_watch_path(card) %>
<%= turbo_frame_tag card, :pin, src: card_pin_path(card) %>
<%= turbo_frame_tag card, :watch, src: card_watch_path(card), data: { turbo_permanent: true } %>
<%= turbo_frame_tag card, :pin, src: card_pin_path(card), data: { turbo_permanent: true } %>
</aside>
<%= render "cards/container/closure", card: card %>