Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to have turbo-ios ignore certain link clicks? #176

Closed
michaelcarter opened this issue Feb 20, 2024 · 5 comments
Closed

Possible to have turbo-ios ignore certain link clicks? #176

michaelcarter opened this issue Feb 20, 2024 · 5 comments

Comments

@michaelcarter
Copy link

michaelcarter commented Feb 20, 2024

I have a page on my Turbo-iOS app where I'm animating navigations between two tabs like so:

tabs-min.mov

This works well on the web. I'm just using a stimulus controller to intercept outgoing and incoming content to apply CSS animations. My HTML is therefore very simple - it just looks like this (CSS classes removed for clarity):

<nav>
    <%= link_to "Matches", matches_url  %>
    <%= link_to "Organisations", organisations_url %>
</nav>

On iOS, I have an issue where can't see these transitions because I'm pushing new native views for each navigation in my app:

tabs-ios-min.mov

To solve this, is there a way to prevent turbo-ios from intercepting certain links? I'd like these specific navigations to just occur within the webview like they would on the web.

Apologies if this is answered somewhere, I've been searching for a couple of hours now for a solution with no luck. Thank you for reading! 🙌

@joemasilotti
Copy link
Member

Does PR #160 solve your issue?

@jayohms
Copy link
Collaborator

jayohms commented Feb 23, 2024

The path to achieve page refreshes without adding onto the nav stack is to use Turbo 8 + same-page refreshes with morphing. See: https://turbo.hotwired.dev/handbook/page_refreshes and #178 which provides full Turbo 8 refresh support.

If you don't want Turbo to handle link clicks at all, you can disable this per-link and use your own custom event listener: https://turbo.hotwired.dev/handbook/drive#disabling-turbo-drive-on-specific-links-or-forms

@jayohms jayohms closed this as completed Feb 23, 2024
@michaelcarter
Copy link
Author

michaelcarter commented Feb 26, 2024

@jayohms - I am not trying to refresh the page in this instance, I'm navigating to a new different URL that just happens to have a similar layout. Is morphing appropriate here?

I’d just like to skip turbo-ios intercepting these link clicks so the turbo navigation happens in the webview. Then my page transition CSS animations would work like they do on the web. I thought maybe there was a way to have turbo-ios ignore certain links, but perhaps not?

Thanks in advance.

@jayohms
Copy link
Collaborator

jayohms commented Feb 26, 2024

I am not trying to refresh the page in this instance, I'm navigating to a new different URL that just happens to have a similar layout. Is morphing appropriate here?

No, this isn't possible. Morphing with Turbo 8 in the browser works when the url paths are the same. Morphing between different urls is not supported.

I’d just like to skip turbo-ios intercepting these link clicks so the turbo navigation happens in the webview. Then my page transition CSS animations would work like they do on the web. I thought maybe there was a way to have turbo-ios ignore certain links, but perhaps not?

No, this works against the design of the library. The main benefit of the library is to give you a native ViewController backstack when navigating between different urls. Disabling certain urls to avoid that behavior would be against the design of the library and is not supported.

@michaelcarter
Copy link
Author

@jayohms Ok, thanks for the clarification. I'll work around it for now and seek a native solution in time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants