-
Notifications
You must be signed in to change notification settings - Fork 436
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
changing turbo frame src manually doesn't update main url #468
Comments
This is a current limitation that is likely to stick around in In cases where you need to promote a Frame Visit to a Page Visit programmatically (like in a Stimulus Controller), you could synthesize an function promoteToFrameVisit(element /*: FrameElement */, src /*: string */, action = "advance") {
const link = document.createElement("a")
link.setAttribute("href", src)
link.setAttribute("data-turbo-action", action) // you can skip this is the <turbo-frame> already declares [data-turbo-action]
link.setAttribute("hidden", "")
element.appendChild(link)
link.click()
element.removeChild(link)
}
promoteToFrameVisit(this.frameTarget, "/", "replace") Alternatively, the To share a little extra context, the current internal structure of the Turbo Frames portion of the codebase makes it challenging to retain contextual information throughout a Frame navigation. For example, once an There are efforts in-progress to refactor and restructure the Turbo internals , but they're unlikely to ship until a stable |
Closes [hotwired#489][] Closes [hotwired#468][] First, add test coverage to exercise the `<turbo-frame id="frame">` and `<turbo-frame id="hello" target="frame">` as outlined in a [comment on hotwired#489][]. Next, add coverage to support driving a `<turbo-frame data-turbo-action="advance">` through the `Turbo.visit` method. To pass that test coverage, invoke `frameElement.delegate.proposeVisitIfNavigatedWithAction(frameElement)` prior to modifying the element's `[src]` attribute. To support the implementation changes necessary to pass the tests, this commit makes one change to the public interface, and another to an internal interface. * `FrameElement.getElementById(id: string)` - unify the process to internally resolve a `<turbo-frame>` element by its `[id]`. Update call sites to use this new method * `FrameController.proposeVisitIfNavigatedWithAction(frame, action)` - flatten the variable arguments into a single `action` argument. Move the `getVisitAction` call to the call sites that require it, and pass in the `action` directly when its available [hotwired#489]: hotwired#489 [hotwired#468]: hotwired#468 [comment on hotwired#489]: hotwired#489 (comment)
Closes [hotwired#489][] Closes [hotwired#468][] First, add test coverage to exercise the `<turbo-frame id="frame">` and `<turbo-frame id="hello" target="frame">` as outlined in a [comment on hotwired#489][]. Next, add coverage to support driving a `<turbo-frame data-turbo-action="advance">` through the `Turbo.visit` method. To pass that test coverage, invoke `frameElement.delegate.proposeVisitIfNavigatedWithAction(frameElement)` prior to modifying the element's `[src]` attribute. To support the implementation changes necessary to pass the tests, this commit changes the `proposeVisitIfNavigatedWithAction(frame, action)` interface by flattening the variable arguments into a single `action` argument, then moving the `getVisitAction` call to the call sites that require it. The call sites that know their `action` pass it in directly when its available. [hotwired#489]: hotwired#489 [hotwired#468]: hotwired#468 [comment on hotwired#489]: hotwired#489 (comment)
Closes [hotwired#489][] Closes [hotwired#468][] First, add test coverage to exercise the `<turbo-frame id="frame">` and `<turbo-frame id="hello" target="frame">` as outlined in a [comment on hotwired#489][]. Next, add coverage to support driving a `<turbo-frame data-turbo-action="advance">` through the `Turbo.visit` method. To pass that test coverage, invoke `frameElement.delegate.proposeVisitIfNavigatedWithAction(frameElement)` prior to modifying the element's `[src]` attribute. To support the implementation changes necessary to pass the tests, this commit changes the `proposeVisitIfNavigatedWithAction(frame, action)` interface by flattening the variable arguments into a single `action` argument, then moving the `getVisitAction` call to the call sites that require it. The call sites that know their `action` pass it in directly when its available. [hotwired#489]: hotwired#489 [hotwired#468]: hotwired#468 [comment on hotwired#489]: hotwired#489 (comment)
Closes [#489][] Closes [#468][] First, add test coverage to exercise the `<turbo-frame id="frame">` and `<turbo-frame id="hello" target="frame">` as outlined in a [comment on #489][]. Next, add coverage to support driving a `<turbo-frame data-turbo-action="advance">` through the `Turbo.visit` method. To pass that test coverage, invoke `frameElement.delegate.proposeVisitIfNavigatedWithAction(frameElement)` prior to modifying the element's `[src]` attribute. To support the implementation changes necessary to pass the tests, this commit changes the `proposeVisitIfNavigatedWithAction(frame, action)` interface by flattening the variable arguments into a single `action` argument, then moving the `getVisitAction` call to the call sites that require it. The call sites that know their `action` pass it in directly when its available. [#489]: #489 [#468]: #468 [comment on #489]: #489 (comment)
Hi, is this a bug or something intentionally left out? On latest turbo release.
When using a turbo frame with the new data-turbo-action="advance" directive ie:
When manually selecting the turbo frame and changing the src in stimulus controller
ie
frameTarget.src = '/'
it only changes the src of the frame, not url.It would be nice to be able to change the src programmatically and have it sync with the main url as well, like normal link clicks. Thanks, let me know what you think, or if I missed something.
The text was updated successfully, but these errors were encountered: