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

Add ability to click link in a frame with a data-turbo-stream="true" #1152

Conversation

loqimean
Copy link

@loqimean loqimean commented Jan 31, 2024

So, I guess it would be fine to have the ability to change the URL with turbo_stream request for some reason: when you have pagination or other type of request, like filters, you need to provide for user URL with its parameters, so in my case me too need. So, with this type of pages-request you'll update the page by parts with turbo_stream but it affects the URL, and the only way to solve it is to use JS code like stimulusUse with its mutate or create some workarounds that solve It by handling turbo events.
So, when contributors added the ability to create a turbo_stream with a GET request we also need the ability to show this GET request for the browser to add an ability for the user to share it, or find it, to be on the same page after page reloading. So, let me solve this problem, help or just complete this issue, please
solves #1151
solves #792

@loqimean
Copy link
Author

@afcapel @dhh check it please and let me now If I need something improve or change, it's just my first great contribution to a big repository, thanks!

@brunoprietog
Copy link
Collaborator

I'm afraid that this is the expected behavior. Turbo streams are not intended, in principle, to alter the browsing history, only to make changes to the DOM. At least that's how I understand it.

So, it's possible to have a controller that reacts to a request that is in Turbo stream format, so that this controller responds with the Turbo stream actions that were requested by the call to the controller. But that controller is not necessarily prepared to receive normal HTML requests, so if you change the URL in the browser and a user, for example, refreshes the page, or simply clicks on a link and then goes back and caching is disabled on that page, will get a blank page. This could break many applications eventually.

@loqimean
Copy link
Author

loqimean commented Feb 1, 2024

I'm afraid that this is the expected behavior. Turbo streams are not intended, in principle, to alter the browsing history, only to make changes to the DOM. At least that's how I understand it.

So, it's possible to have a controller that reacts to a request that is in Turbo stream format, so that this controller responds with the Turbo stream actions that were requested by the call to the controller. But that controller is not necessarily prepared to receive normal HTML requests, so if you change the URL in the browser and a user, for example, refreshes the page, or simply clicks on a link and then goes back and caching is disabled on that page, will get a blank page. This could break many applications eventually.

Sure, I got your point, what I should when I need to load some parts of html by turbo_stream, but it is filters page and I'd like to change url, 'cause when user refreshes page there is page without filters. So, what approach you recommend in this case?

@afcapel
Copy link
Collaborator

afcapel commented Feb 2, 2024

You can use data-turbo-action='advance' to update the URL when loading a frame. Hope that helps.

@afcapel afcapel closed this Feb 2, 2024
@loqimean
Copy link
Author

loqimean commented Feb 2, 2024

You can use data-turbo-action='advance' to update the URL when loading a frame. Hope that helps.

But it's not relevant because I don't need turbo-frames, or just give me an example app. It should be page with filtering by url, like page respond to HTML to render whole page and turbo_stream to update parts of page with changing url to have applied filters to this page after reload

@loqimean
Copy link
Author

loqimean commented Feb 2, 2024

@afcapel

@brunoprietog
Copy link
Collaborator

The question is, why do you need Turbo streams for that? Isn't it a typical page navigation? Maybe with the replace action?

@loqimean
Copy link
Author

loqimean commented Feb 2, 2024

The question is, why do you need Turbo streams for that? Isn't it a typical page navigation? Maybe with the replace action?

What do you mean? Like it's typical page navigation but instead of reloading whole page to be navigated to next filtered page version,because of using turbo streams

@brunoprietog
Copy link
Collaborator

What I mean is that you could build these filters with typical form submissions and page navigations instead of Turbo streams using the replace action. That's why I'd like to better understand the use case you need. Even now with morphing there are more options to simplify it. Maybe with that we could suggest an alternative

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

Successfully merging this pull request may close these issues.

3 participants