Turbo-iOS: Break out of frame?

I have a form input field that changes the content. This content is wrapped inside of a turbo frame tag"

<%= turbo_frame_tag :inventory do %>
content...
<% end %>

“content” has links where I use target: :_top to break out of the frame when clicked else you’d get “Content Missing”. Now I use Turbo iOS. When a link is clicked, it tries to open the browser instead of pushing the view onto the stack. To get around this, I’d have to remove the wrapping turbo frame tag and remove the target attribute which is not ideal. How to solve this?

My turbo ios session:

func session(_ session: Session, openExternalURL url: URL) {
    let safariViewController = SFSafariViewController(url: url)
    present(safariViewController, animated: true, completion: nil)
}

If no solution I’d have to make this page native.

1 Like

I know this is an old post now, but just hit this exact same issue.

Used target: “_top” on a link_to within a turbo frame, and those links now open in a safari modal in turbo-ios. Thankfully I had a keen-eyed user spot this and let me know asap

2 Likes

I also ran into this issue, and luckily I found that the fix is to use data-turbo-frame instead of the target attribute: ruby on rails - Hotwire/Turbo Frames: why `target: "_top"` isn't requesting pages via fetch? - Stack Overflow. It’s not Hotwire Native specific, but rather using this attribute seems to allow Turbo to continue handling the request while maintaining the behavior of replacing the full page. There’s an example of this attribute on Turbo Handbook but I don’t fully understand it, but it does seem to work well for me on both Hotwire Native and desktop web.