hotwired / turbo

The speed of a single-page web application without having to write any JavaScript
https://turbo.hotwired.dev
MIT License
6.71k stars 427 forks source link

Kaminari page lost when submitting form #494

Closed alhafoudh closed 4 months ago

alhafoudh commented 2 years ago

I have a paginated list of orders. Each order can be completed by link next to each order like this:

link_to 'Complete', complete_order_path(order), data: { turbo: true, turbo_method: :patch }

The order is updated in controller like this:

...
  def complete
    @order = Order.find(params[:id])

    @order.completed_at = Time.zone.now
    @order.save!

    redirect_back fallback_location: orders_url, status: :see_other
  end
...

When I navigate to some page of orders, the params change to for example /orders?page=3. After clicking the "Complete" link the turbo-frame updates, but I get first page of orders rendered, because the turbo-frame loses params of the page and the Referer header is the original _top page URL.

How can I fix this in turbo?

pinzonjulian commented 2 years ago

Hey @alhafoudh !

Usually the Github issue tracker is used to report issues and bugs with the library as opposed to asking for help on specific implementation details of your app.

I recommend you post this question in the official hotwired forum at http://discuss.hotwired.dev or maybe join the StimulusReflex discourse here https://discord.gg/stimulus-reflex.

If after discussing there you realise you might have found a bug in Turbo, by all means, create an issue.

pinzonjulian commented 2 years ago

Tag me in any of those places and I'll give you a hand.

brunoprietog commented 10 months ago

Do you think you can close this? We can see it in the discussions forum

alhafoudh commented 10 months ago

Yes, sure. Thanks @brunoprietog