-
Notifications
You must be signed in to change notification settings - Fork 428
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
Display progress bar on form submissions #317
Conversation
cc @jayohms |
@dhh Is this the behavior that we want for all form submissions? I think there will be situations where it will visually make more sense to localize the progress indicator in/around the form, especially if the form is in a small portion of the screen. For example, in HEY, we display a loading indicator directly on our submit buttons during the Sign Up flow (among other places). With the approach in the PR, is there an option available to easily customize the behavior? In the HEY mobile apps, we currently use the |
I think having a progress bar as a default on the same heuristics as visits, like it doesn't kick in until 200ms or whatever it is, is good. But yes, you should be able to cancel that entirely if you have your own setup. Just that by default we should mimic what the browsers do naturally, just like we do with visits. |
Just chiming in that it wasn't clear to me that the progress bar would not appear on form submissions, and I wish I could enable it (like this PR!). Thinking about the first-time user experience, it seems to me that slow POST requests would happen often before slow GET requests. |
@jayohms Does this need updating of the native adapters before we can merge? |
@terracatta Can you bring the tests over as well? |
The mobile adapters will need to be updated to support the API, which isn't a big deal - however there will be adapters in the wild that will not have the updated adapter methods. So this PR will need to account for the fact that the adapter methods might not be available. We don't want javascript errors to break requests. |
@jayohms, that's kinda what I thought. @terracatta could you have a look at making sure this only calls this method if the adapter has implemented it? |
@dhh yep, I'll take a look this weekend. |
@dhh ok, I added back the tests and added a check to make sure the adapter implements the methods before calling it. As for your comment about being able to override this behavior if you have your own setup. What did you have in mind? Something like calling |
This looks good. Would just like to validate that it indeed does not throw any halting JS errors with the native adapters. @jayohms We don't actually need any specific opt-out, given that the adapter could just not implement it, right? |
Correct, we don't need a specific opt-out. The native libraries will end up implementing the js adapter methods and expose native APIs to the apps, but the UI behavior will be up to each app to customize on the native side.
The approach is safe with the native adapters 👍 |
901b1d5
to
3dcf23a
Compare
@dhh, it doesn't look like this is in v7.1.0. Will there be a 7.2.0 tagged soon? |
Fixes #61
Note: This PR is simply an extraction from the unmerged PR #164.
Description
Currently when forms are submitted using Turbo Drive there is no progress bar shown when the request is taking a bit. This PR fixes that by bolting on two new formSubmission methods to the generic Adapter interface and implementing them in the browser adapter.
Android/iOS considerations
While I know extending the adapter interface could make extra work for the
turbo-ios
andturbo-android
maintainers, I think there might be enough differentiated behavior in form submissions to make separate methods a better choice in the long-term vs genericizing thevisitRequestStarted
andvisitRequestFinished
methods.