Enable frame morphing for data-turbo-frame links and forms if the URL doesn't change #1316
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi folks, this PR is aimed at enabling another specific use-case for morphing
turbo-frame[refresh=morph]
that isn't currently supported.Status quo:
Right now, if one clicks a link or submits a form that contains
data-turbo-frame
, that target frame is replaced without morphing, even ifrefresh=morph
. This makes sense if the frame is navigating to a different URL, because its not a "refresh" operation at all; it's more of a navigation operation.Motivating use-case:
However, I propose that in some common idiomatic situations these operations are indeed refreshes, and therefore should be morphed. Imagine a turbo-frame with a list of blog posts, and an external new post form, which targets the blog post list. I submit for your consideration that in this situation, submitting the form is indeed refreshing the frame.
Proposed solution
If a morphing frame's URL changes from the result of a link click or form submission, keep the current behavior and render it with the normal replacement rendering. If the URL does NOT change, however, consider it a refresh and use morphing.
Final notes
Please let me know if this PR is an idea worth considering for merging, and if so I'll do a bit more work here. I think it could use some more tests to fully nail down all the permutations it implies.
Thanks for your time, and continued work on Turbo!