-
Notifications
You must be signed in to change notification settings - Fork 423
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
Support replacing state #335
Comments
Hi @boardfish, If you try with this command: Cheers, |
Thanks @tortuetorche, that appears to have worked. I ended up using the following: window.Turbo.navigator.history.replace(new URL(this.turboFrameTarget.src, `${window.location.protocol}//${window.location.host}`)) |
@boardfish When constructing a new URL instance, have you tried passing the value of Node.baseURI as the second argument? const { src, baseURI } = this.turboFrameTarget
const url = new URL(src, baseURI) |
I didn't know that was a thing! Good shout - thanks @seanpdoyle ✨ |
While it works almost OK, I bet it is not necessarily what a user might expect. Two issues:
This is what I've come up with instead: #792 (comment) It feels a little bit hackish and I'd love to have a cleaner way to update URLs from the stream responses. |
As highlighted here, if I use
Turbo.navigator.history.replace({ absoluteURL: '/posts/1/edit' })
to replace the current state, I get the following error when clicking a link on the page:The link is inside a Turbo frame which has
target="_top"
set.Since Turbo's own history breaks under native
window.history.replaceState
, it'd be good to have a supported alternative in a similar way to how Turbo callbacks replace$(document).ready()
in jQuery, for example.The text was updated successfully, but these errors were encountered: