Fix back navigation from activity page to cards (#2727)
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
This commit is contained in:
@@ -24,8 +24,9 @@ export default class extends Controller {
|
||||
referrerBackLinkTargetConnected(link) {
|
||||
if (!this.#referrerUrl || !this.#referrerLabel) { return }
|
||||
|
||||
const allowedPaths = (link.dataset.turboNavigationAllowedReferrerPaths || "").split(",")
|
||||
const referrerPath = new URL(this.#referrerUrl).pathname
|
||||
const stripTrailingSlash = path => path.replace(/\/$/, "")
|
||||
const allowedPaths = (link.dataset.turboNavigationAllowedReferrerPaths || "").split(",").map(stripTrailingSlash)
|
||||
const referrerPath = stripTrailingSlash(new URL(this.#referrerUrl).pathname)
|
||||
if (!allowedPaths.includes(referrerPath)) { return }
|
||||
|
||||
link.href = this.#referrerUrl
|
||||
|
||||
Reference in New Issue
Block a user