Skip to content

Unable to Disable Turbo Streams on a Form #1361

Open
@justwiebe

Description

I have a POST login form that redirects to the page that the user was trying to go to on success. Because it's a redirect, the text/vnd.turbo-stream.html Accept header is copied over to the new GET request. This causes issues on some pages that support turbo streams (the root path in my case) because they'll incorrectly determine that the request is a turbo stream request and the response is nothing that my login form is capable of interpreting.

It would be really useful if https://github.com/hotwired/turbo/blame/ae14a60e7a5784deeb54cadeb47778693855c57f/src/core/drive/form_submission.js#L211 respected a data-turbo-stream="false" for such cases. I tried disabling turbo altogether (data-turbo="false") but then that seems to interfere with Turbo-Native, and the login form does nothing in mobile apps.

Devise login form:

= simple_form_for resource, as: resource_name, url: session_path(resource_name), data: { turbo_action: :replace } do |f|
  .card__body
    h1.login__header Login
    = f.input :username
    = f.input :password
  .card__footer
    .actions
      = render "devise/shared/links"
      button.btn.btn-primary type="submit" Log In

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions