Skip to content

Add 'data-turbo' => 'false' in markdown link to escape turbo-frames#1136

Merged
amatsuda merged 1 commit into
rubycentral:mainfrom
unasuke:target-brank-to-url-in-markdown
Jul 11, 2026
Merged

Add 'data-turbo' => 'false' in markdown link to escape turbo-frames#1136
amatsuda merged 1 commit into
rubycentral:mainfrom
unasuke:target-brank-to-url-in-markdown

Conversation

@unasuke

@unasuke unasuke commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What

Links inside internal comments live within the rating widget's turbo-frame, so clicking a comment URL triggered a frame navigation whose response lacked that frame, rendering "Content missing".

Screenshots

before

2026-07-11.175226.mp4

after

2026-07-11.175143.mp4

ref

@amatsuda

Copy link
Copy Markdown
Collaborator

@unasuke Nice find on the root cause — links inside the rating widget's turbo-frame really were broken ("Content missing"), and link_attributes is the right layer to fix it (verified it applies to both explicit links and autolinked URLs, and filter_html means users can't produce an <a> that bypasses it).

One concern about the chosen attribute, though: target="_blank" changes link behavior on every markdown surface, not just the framed ones. Of the 8 markdown() call sites, only three sit inside turbo-frames and had the bug (rating widget, staff guidelines, proposal preview). The rest change behavior as a side effect:

  • the public events/show guidelines page — every link (including relative CTAs like "submit a proposal") now opens a new tab for anonymous visitors
  • anchor links: [see below](#section) renders <a href="#section" target="_blank"> and opens a useless duplicate tab instead of scrolling
  • autolinked emails: bare cfp@example.org becomes a target="_blank" mailto, which leaves an orphaned blank tab in several browsers
  • the speaker-email-template preview now shows attributes the actual sent mail (rendered by ApplicationMailer's separate renderer) won't have

Since this app sets Turbo.session.drive = false (links are only ever intercepted by frames), the same one-line fix without any of those side effects is:

MarkdownRenderer.new(filter_html: true, hard_wrap: true, link_attributes: {'data-turbo' => 'false'})

Frame link-interception respects data-turbo="false", so links inside the rating widget (and the other two framed surfaces) navigate natively same-tab — bug fixed, zero behavior change everywhere else, and no tabnabbing surface to mitigate. ('data-turbo-frame' => '_top' is the variant if a Turbo page-visit is preferred.)

@unasuke

unasuke commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

target="_blank" changes link behavior on every markdown surface, not just the framed ones

Yes. And I'd been thinking this was acceptable. Indeed, I had overlooked the side effects for anchor links and autolinked emails. I'll go ahead and adopt the proposed correction.

Links inside internal comments live within the rating widget's turbo-frame,
so clicking a comment URL triggered a frame navigation whose response lacked
that frame, rendering "Content missing".

Since Turbo Drive is disabled app-wide, links are only ever intercepted when
inside a turbo-frame. Marking rendered links data-turbo="false" makes those
frame-internal links navigate natively in the same tab (fixing the bug) while
being a no-op everywhere else -- no new-tab side effects on other markdown
surfaces (public guidelines, anchor links, autolinked emails, mail preview)
and no tabnabbing surface to mitigate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@unasuke unasuke force-pushed the target-brank-to-url-in-markdown branch from 2c96025 to 33d51c1 Compare July 11, 2026 12:21
@unasuke unasuke changed the title Open markdown links in a new tab to escape turbo-frames Add 'data-turbo' => 'false' in markdown link to escape turbo-frames Jul 11, 2026
@unasuke

unasuke commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

@amatsuda Applied {'data-turbo' => 'false'} and works intended.

2026-07-11.212215.mp4

@amatsuda amatsuda merged commit 73723c7 into rubycentral:main Jul 11, 2026
1 check passed
@amatsuda

Copy link
Copy Markdown
Collaborator

@unasuke Thank you!

@unasuke unasuke deleted the target-brank-to-url-in-markdown branch July 11, 2026 12:57
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