Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Shouldn't the default visit option still be advance? #10

Open
dsander opened this issue Jun 18, 2016 · 3 comments
Open

Shouldn't the default visit option still be advance? #10

dsander opened this issue Jun 18, 2016 · 3 comments

Comments

@dsander
Copy link

dsander commented Jun 18, 2016

I noticed the default visit option changed from advance to replace, I don't understand in which use case that would be desirable.

To my understanding visit_location_with_turbolinks is only executed for xhr requests which aren't GETs , thus never triggered by Turbolinks.visit.
That means that calling Turbolinks.visit(location, "replace") will override the history location of the XHR request with the redirection target and navigating back will skip the page that issued the XHR request.
I would expect the default to still be advance, because the location of the XHR call is never put in the browser location history.

@benoitongit
Copy link

I had the same expectation, was surprised when I saw that the default was 'replace'

@artemave
Copy link

Defaulting to "replace" breaks back button on form submit. Instead of going back to the form - local form behavior - it goes to the page before the form.

@timdiggins
Copy link

Agreed. For future reference, I got around this by wrapping redirect_to in my ApplicationController as follows:

  # override Turbolinks.redirect_to to make "advance" the default
  def redirect_to(url = {}, options = {})
    options[:turbolinks] = "advance" unless options.key?(:turbolinks)
    super(url, options)
  end

It feels like it would be useful to make this configurable, maybe with new installs having the new default (just switching the default might be too much of a change). However that sounds like it would need to have a proper test suite for this. Are any maintainers/contributors around to give a point of view?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants