You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a user submits a form in my Rails 7 application the submit button is disabled. After a form is submitted the user is redirected to another page. In between the moment that the form is submitted and the user is actually redirected the submit button is suddenly enabled again. This is similar behavior as described in this old issue in rails-ujs rails/rails#31441 (see GIFs in that issue). For an end user this might seem strange and it seems like a bug to me. Note, I am not using rails-ujs. In that pull request they fixed the issue by not enabling disabled elements for XHR redirects.
In #386 a change was made for disabling/enabling submit buttons. This pull request states "If callers need to control the submitter's disabled attribute more finely, they can declare listeners to do so.". Since the button is enabled again in Turbo's FormSubmission.requestFinished method just before dispatching a TurboSubmitEndEvent, I can workaround this problem by re-disabling the button myself again by declaring a listener on turbo:submit-end:
The disabled attribute being removed too early when redirecting presents a very confusing message to the user. The old UJS behaviour was easy to use and did what it should, but the new Turbo implementation seems to be lacking as it's not providing the same level of support.
Hi,
I am facing the following problem:
When a user submits a form in my Rails 7 application the submit button is disabled. After a form is submitted the user is redirected to another page. In between the moment that the form is submitted and the user is actually redirected the submit button is suddenly enabled again. This is similar behavior as described in this old issue in rails-ujs rails/rails#31441 (see GIFs in that issue). For an end user this might seem strange and it seems like a bug to me. Note, I am not using rails-ujs. In that pull request they fixed the issue by not enabling disabled elements for XHR redirects.
In #386 a change was made for disabling/enabling submit buttons. This pull request states "If callers need to control the submitter's disabled attribute more finely, they can declare listeners to do so.". Since the button is enabled again in Turbo's
FormSubmission.requestFinished
method just before dispatching aTurboSubmitEndEvent
, I can workaround this problem by re-disabling the button myself again by declaring a listener onturbo:submit-end
:Although this seems to work, I think this should be fixed in Turbo.
Is it maybe an idea to change the
requestFinished
method inform_submission.ts
to something like:If so, I could open a pull request to fix this.
The text was updated successfully, but these errors were encountered: