Closed i108 closed 6 years ago
I think you're looking for this: https://github.com/turbolinks/turbolinks-ios#handling-form-submission
I am using form_with which should handle the form submission fine and does. Looking at the server logs, looks like the resulting redirect is also followed by the framework. However, the callback which leads to the dismissal of the authentication controller is never triggered.
In the demo, it uses a non-Turbolinks redirect and delegate from the AuthenticationController to inform the application controller that authentication is complete which triggers the dismissal of the modal - https://github.com/turbolinks/turbolinks-ios/blob/master/TurbolinksDemo/ApplicationController.swift#L107.
If you're getting a Turbolinks redirect from your form submission, you'll have to handle that differently in your application code. In Basecamp, we have a "navigator" that is responsible for performing the navigation, including handling dismissing modals when necessary.
Awesome .. thanks for the response.
I tried setting window.location in the xhr response to work around Turbolinks for the sign in request and the modal was dismissed as expected.
I'll stick to this solution for now.
I ran into unexpected behaviour when using the Demo app style Authentication Controller and Turbolinks 5.
While the Demo app with the bundled Sinatra stub app works fine .. when I switch over to Rails (which introduces Turbolinks into the picture) things are not so kosher
Server is returning a 401 for unauthorized requests. The sign_in form is using form_with which seems to submit fine on the server leading to successful authentication. The post-login successful redirect seems to be followed by Turbolinks based on the server logs, however, the Authentication View stays put .. it seems the callback which dismisses it is never invoked
extension AuthenticationController: WKNavigationDelegate { func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
How may I remedy this?