Skip to content

Fix back navigation from activity page to cards#2727

Merged
flavorjones merged 1 commit into
mainfrom
card-navigate-back-to-activity
Mar 19, 2026
Merged

Fix back navigation from activity page to cards#2727
flavorjones merged 1 commit into
mainfrom
card-navigate-back-to-activity

Conversation

@flavorjones

Copy link
Copy Markdown
Member

Summary

  • Add root_path to the prefer_referrer allowlist on the card show page so the back link can be rewritten when coming from the activity page
  • Switch event card 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

Test plan

  • System test: navigate from activity page → card → back link says "Back to Home" and returns to activity
  • System test: same flow works when activity URL has no trailing slash
  • Existing back link tests still pass (board filter, global filter, non-filter page)

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
Copilot AI review requested due to automatic review settings March 18, 2026 21:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") so turbo:before-visit fires 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.

@flavorjones
flavorjones merged commit 11df9c3 into main Mar 19, 2026
17 checks passed
@flavorjones
flavorjones deleted the card-navigate-back-to-activity branch March 19, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants