-
Notifications
You must be signed in to change notification settings - Fork 329
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
turbo_refreshes_with morph-reset, replace-preserve #536
Comments
I noticed that when you do not provide But if you use |
This is more a question of what the Turbo library itself supports functionally (
Is actually useful or intended to be used, really. By using "replace" you're indicating that there's a navigation to a new 'content page' which typically means scroll should reset so the user can begin seeing/grokking the content anew. So pairing it with On the other hand, and the very reason I believe the Turbo team opted to split the
Has legitimate use-cases. I can't tell you exactly what they are, but I recall someone on the HEY Calendar team mentioning that the Calendar workflow has a couple of places where morphing was appropriate (so some kind of page refresh / update to an existing content page; not a navigation to a new content page) but even in staying on the same content page, resetting the scroll felt appropriate / necessary too. Maybe think of a long form with lots of markup content and when you submit that form you get back a "Thanks!" followed by lots of follow-up instructions / markup. There might be a case there where you want to morph because you're still looking at the same canonical content page, but perhaps reset the scroll to help the user start reading the instructions fresh. |
I have a use case where the following is needed: turbo_refreshes_with method: :replace, scroll: :preserve I use the chartkick gem to render charts with js. The chart is refreshed only if I use the replace method. In case of morphing then chart is not rendered on the refresh. |
I imagine that kind of scenario is more of an implementation detail / issue with how the morphing works (noted in hotwired/turbo#1083) rather than a functional desire for replace+preserve. E.g., if morphing did preserve your charts, you'd probably use morphing then? |
You are correct. |
Indeed, I've been having the same issue with stimulus controllers not reconnecting (for example a dropdown not staying open after morph. Combining these methods in various ways helped me:
|
FYI hotwired/turbo#1097 aims to help with some of these ^. I imagine it'll be merged soon |
Hi! I currently see 2
turbo_refreshes_with
options:Are there any scenarios where
replace-preserve
, morph-reset` would be preferable? If not, why is this possible?The text was updated successfully, but these errors were encountered: