Skip to content

Conversation

@piaccho
Copy link
Collaborator

@piaccho piaccho commented Jun 17, 2025

Summary

This PR provides a comprehensive fix for issues with Strada Bridge Components that occur after Turbo Frame navigations or redirects. It ensures that components remain active and that native iOS state remains synchronized, correcting functionality like pull-to-refresh.

This PR addresses two problems - #228 and iOS Pull-to-Refresh regression. To fix the iOS regression, this PR introduces an approach similar to what was mentioned in #227 - it has been resolved by adding a Key-Value Observer to the WKWebView's url property in RNVisitableView.swift. This restores pull-to-refresh and ensures native state consistency.

Test plan

We can test both Bridge components and pull-to-refresh functionalities work as expected by using the specific branch of the demo server.

This branch of the demo web app includes Strada Components flow that can be used to test them.

This can be checked out and the demo app pointed to the local running version of the test server.

Demo

Functionalities tested on this version of demo web app.

demo.mov

@piaccho piaccho requested a review from pklatka June 17, 2025 11:31
Comment on lines +112 to +114
if controller.visitableURL != newUrl {
controller.visitableURL = newUrl
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Shouldn't we notify the JS side that the url has been changed by Turbo? I guess this is fine when you do the replace action, but what about the advance? Don't know if this is even possible with Turbo.
  2. This feels hakish -> in this case there should be a small comment explaining this or a link to a GH issue.

Copy link
Contributor

@pfeiffer pfeiffer Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we notify the JS side that the url has been changed by Turbo? I guess this is fine when you do the replace action, but what about the advance? Don't know if this is even possible with Turbo.

We could investigate if it'd make sense to trigger the onLoad prop on the JS-side.

The change here with KVO ensures visitableURL on the iOS is kept in-sync, so that pull-to-refresh will refresh the URL correctly after history.push(..) (eg. via Turbo Frame JS navigations on-site that do not go through the normal Turbo advance or replace flow)

On Android, the pull-to-refresh works without similar change. If we trigger onLoad on history changes on iOS, we probably want similar behavior on Android. I haven't been able to figure out how we could get similar behavior on Android though without resorting to some exotic solutions. One solution on Android is to monkey-patch history.push by injecting some JS into the WebView, but this feels very hackish.

This` feels hakish -> in this case there should be a small comment explaining this or a link to a GH issue.

I think the solution is actually quite elegant, but agree that we probably need to add some comments as to what this does and why.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ll add a clarifying comment explaining the motivation behind it.

Good point on triggering onLoad from the native side to notify JS — that could help keep things better in sync. Do you think it makes sense to explore that in this PR, or should we track it as a follow-up so we can keep this focused on fixing the pull-to-refresh issue first?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be tracked as a follow-up.

@piaccho piaccho requested review from pfeiffer and pklatka June 23, 2025 10:55
Comment on lines +112 to +114
if controller.visitableURL != newUrl {
controller.visitableURL = newUrl
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be tracked as a follow-up.

@piaccho piaccho merged commit acc9cc8 into main Jun 23, 2025
1 check passed
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.

4 participants