Skip to content
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

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

Closed
jdrosales17 opened this issue Nov 14, 2024 · 2 comments
Closed

Comments

@jdrosales17
Copy link

jdrosales17 commented Nov 14, 2024

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
@seanpdoyle
Copy link
Contributor

Thanks for opening this issue. This feels related to hotwired/turbo-site#178, particularly: hotwired/turbo-site#178 (comment) (which includes a reproduction script).

I'm not sure of the best path forward. @jdrosales17 would you mind closing this issue, then chiming in on the discussion thread in hotwired/turbo-site#178 (comment)?

@jdrosales17
Copy link
Author

Ohh sure, I will check on that discussion! Thanks for the quick response @seanpdoyle! 🙌

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

No branches or pull requests

2 participants