-
Notifications
You must be signed in to change notification settings - Fork 10
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
When the initial page redirects, the BridgeDelegate.location becomes stale #23
Comments
Confirming that this is reproducible and I'd love to get it fixed! |
joemasilotti
added a commit
that referenced
this issue
Dec 7, 2023
If a Turbo request is redirected to a page with a Strada component this check would always fail. `location` is only set when `BridgeDelegate` is initialized. This change dynamically grabs the URL from the web view, falling back to the original `location` if nil. Fixes #23
Amazing...thanks Joe, let me take it for a spin and let you know how it goes. |
@joemasilotti can confirm #24 fixes this issue! |
Excellent, thanks @adampal! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When the very first URL loaded by a Turbo.VisitableViewController is redirected by the Rails app, the
location
constant in the BridgeDelegate is set to the initial URL, not the redirected URL. As a result, any BridgeComponents on the page will ignore messages because thelocation
does not match themessage.metadata?.url
.Any subsequent page loads, even if they include redirects, will set the
location
correctly and BridgeComponents will work.I created minimal Rails and iOS repos to reproduce the bug. The Rails repo is a basic
rails new
with all the defaults and really just adds thebridge--hello
controller and views.The iOS repo starts from the Strada-iOS demo and just adds a
helloComponent
.Each repo only adds a single commit (rails commit, iOS commit) so it's easy to see what I've added/changed to reproduce the bug.
If you clone the repos and run it locally, you can toggle the behaviour by setting the
Demo.current
in the iOS repo to eitherlocal
ornoRedirect
:noRedirect
the rootURL is set to the URL of the first page. The app will load and the BridgeComponent is loaded and works correctly.local
the rootURL is set to a different URL that redirects to the URL of the first page of the app.Even though they both end up on the same page, in the
local
version the BridgeComponent will ignore messages because of the stalelocation
attribute.You can test subsequent page loads by clicking the links in the nav at the top. All subsequent page loads work correctly, whether they redirect or not.
From looking at the Strada debug logs, it seems that when a URL is redirected, we are supposed to get all lifecycle callbacks triggered twice. Once for the initial URL then again for the final destination URL. However, when the very first URL of the application redirects, this doesn't happen and we just end up with one set of lifecycle events.
I think this may actually be a bug in the Turbo-iOS adapter not here in Strada, but I'm hoping someone with more knowledge than me can point me in the right direction of where/how to get it fixed.
The text was updated successfully, but these errors were encountered: