Skip to content

Morphing not working on search form with the default advance action #1339

@jdrosales17

Description

@jdrosales17

Hi,

I was recently playing with morphing on a Rails application, specifically with a search form which made a GET request to the same index action of the page. I found that morphing was not working unless I defined the attribute data-turbo-action="replace" on the form element.

Going through the source code, I found that Turbo considers a page refresh only when the visit.action is replace.

return !visit || (this.lastRenderedLocation.pathname === visit.location.pathname && visit.action === "replace")

I was wondering if that made sense, since in the search request I was doing I may want to preserve the current location and push a new one so that I'm able to go back to previous searches, and that is not possible with the replace action.

This problem could also happen when applying filters on an index page as it would have the same form doing a GET request with the filter params to the same index action.

To give some context these were the versions I was working with:

  • rails -> 7.0.8
  • turbo-rails -> 2.0.11

Metadata

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