Fix back navigation from activity page to cards#2727
Merged
Conversation
Three changes needed to support navigating back from a card to the activity page: - Add root_path to the prefer_referrer allowlist on the card show page - Switch event links from HTML target="_top" to data-turbo-frame="_top" so Turbo handles the navigation and turbo:before-visit fires to save the referrer - Normalize trailing slashes in the referrer path comparison so /account_id and /account_id/ both match ref: https://app.fizzy.do/5986089/cards/2390
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves “back” navigation when opening a card from the Activity (Home) page by ensuring Turbo-driven navigation captures the referrer and that referrer matching is robust to trailing-slash differences.
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.
Changes:
- Allow card back-link referrer rewriting when the referrer is the Activity (root) page.
- Make Activity event card links Turbo-handled (
data-turbo-frame="_top") soturbo:before-visitfires and the referrer is saved. - Normalize trailing slashes when comparing allowed referrer paths vs. the stored referrer.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/system/back_link_navigation_test.rb | Adds system coverage for Activity → Card → Back (including no-trailing-slash Activity URL). |
| app/views/events/event/_layout.html.erb | Updates event card links to use Turbo frame navigation at the top-level. |
| app/views/cards/show.html.erb | Adds root_path to the back-link referrer allowlist for card show. |
| app/javascript/controllers/turbo_navigation_controller.js | Normalizes trailing slashes during allowed-path vs referrer-path comparison. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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.
Summary
root_pathto theprefer_referrerallowlist on the card show page so the back link can be rewritten when coming from the activity pagetarget="_top"todata-turbo-frame="_top"so Turbo handles the navigation andturbo:before-visitfires to save the referrer/account_idand/account_id/both matchTest plan