Morph card title and description on broadcast refreshes#2990
Merged
Conversation
When a card's title or description was edited, other sessions viewing the card never saw the change until a manual reload. The refresh broadcast fired and other sessions morphed, but the title and description sat inside an unconditional data-turbo-permanent wrapper, so every morph skipped them and preserved the stale content. The wrapper existed to solve two real problems: d6b602b made the edit frame permanent so a broadcast refresh couldn't morph away an edit in progress, and 649888d moved the attribute off the frame onto an id-less wrapper div to stop Turbo transplanting the frame and duplicating the Lexxy editor (basecamp/lexxy#263). The side effect was that the exemption applied to every card being viewed, not just to a card being edited. Permanence is now applied only while editing. The morph-guard Stimulus controller, attached to the card edit form, marks the enclosing turbo-frame data-turbo-permanent on connect and removes it on disconnect. Display mode morphs normally and an open editor still survives refreshes. The attribute never appears in server-rendered markup, so Turbo never transplants the frame across page loads and the lexxy#263 dup can't recur (its underlying bug was also fixed upstream in basecamp/lexxy#474, included in the 0.9.23 we pin).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes stale card title/description during Turbo broadcast refreshes by scoping data-turbo-permanent to edit mode only, so display mode can morph normally while an in-progress editor is still protected from refresh morphs.
Changes:
- Remove unconditional
data-turbo-permanentwrapper from the card content container so broadcast refreshes can update title/description. - Add a
morph-guardStimulus controller that marks the enclosingturbo-framepermanent only while the edit form is connected. - Add a system test suite (
CardRefreshTest) that exercises refresh/morph behavior in view/edit/cancel scenarios and centralize the Lexxy test helper.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/system/smoke_test.rb | Removes a local Lexxy helper now shared via the system test base class. |
| test/system/card_refresh_test.rb | Adds end-to-end system coverage for broadcast refresh behavior in view/edit/cancel flows. |
| test/application_system_test_case.rb | Centralizes fill_in_lexxy helper for system tests. |
| app/views/cards/edit.html.erb | Attaches morph-guard controller to the card edit form (edit-mode-only permanence). |
| app/views/cards/container/_content.html.erb | Removes unconditional permanent wrapper so title/description can morph on refresh. |
| app/javascript/controllers/morph_guard_controller.js | New Stimulus controller that toggles data-turbo-permanent on the enclosing frame while editing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a card's title or description was edited, other sessions viewing
the card never saw the change until a manual reload. The refresh
broadcast fired and other sessions morphed, but the title and
description sat inside an unconditional data-turbo-permanent wrapper,
so every morph skipped them and preserved the stale content.
The wrapper existed to solve two real problems: d6b602b made the
edit frame permanent so a broadcast refresh couldn't morph away an
edit in progress, and 649888d moved the attribute off the frame onto
an id-less wrapper div to stop Turbo transplanting the frame and
duplicating the Lexxy editor (basecamp/lexxy#263). The side effect
was that the exemption applied to every card being viewed, not just
to a card being edited.
Permanence is now applied only while editing. The morph-guard
Stimulus controller, attached to the card edit form, marks the
enclosing turbo-frame data-turbo-permanent on connect and removes it
on disconnect. Display mode morphs normally and an open editor still
survives refreshes. The attribute never appears in server-rendered
markup, so Turbo never transplants the frame across page loads and
the lexxy#263 dup can't recur (its underlying bug was also fixed
upstream in basecamp/lexxy#474, included in the 0.9.23 we pin).