Redirect with anchor and Turbo

I tried redirecting to a path with anchor specified (redirect_to root_path, anchor: 'anchor')) during turbo stream response but it always goes to the top of the page (as if anchor was not specified). Is there a way to make TURBO_STREAM redirect handle anchors?

1 Like

Having this issue with latest hotwire-rails gem
[Redirect with anchor is not handled correctly · Issue #15 · hotwired/hotwire-rails · GitHub](Redirect with anchor is not handled correctly · Issue #15 · hotwired/hotwire-rails · GitHub

I see there was discussion but not sure the outcome: https://github.com/hotwired/turbo/issues/211

I really need to redirect with an anchor. Based on the comments at HTTP 303 Redirects with anchor not respected · Issue #211 · hotwired/turbo · GitHub, I disabled Turbo with “data-turbo”: “false” and changed the link_to to a button_to. Unfortunately, I started getting an error: Can’t verify CSRF token authenticity. I found another workaround using JS but… too many workarounds… Anyone have any suggestions?