-
Notifications
You must be signed in to change notification settings - Fork 430
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
Use Bardo for all permanence handling to fix lost permanent elements in reordering morphs #1308
Use Bardo for all permanence handling to fix lost permanent elements in reordering morphs #1308
Conversation
Idiomorph looks like its going through a bit of a dry spell with regards to maintenance, so I'm going to pursue the Bardo integration path. |
Okay, I got these tests passing with only using the delete key! Love it. However, some other tests are now failing, and one of them in particular strikes me as incorrectly passing on main: turbo/src/tests/functional/page_refresh_tests.js Lines 273 to 286 in 0cc9508
That last assertion! Should the input's value really be preserved in this case?? It doesn't have For ease, here's a link to the fixture it's operating on: |
Huh, also, that next test exposes inconsistencies because |
3dc47bb
to
23791a0
Compare
Okay, I've got something working here. This PR resolves the initial bug by using
Also, the weird test behavior above turned out to be due to the test fixture setting up a global focus event listener, which toggled Overall, I think the alternative to this PR would be to attempt to enhance Idiomorph's core algorithm to better handle morphs involving reorders. I'd be willing to give this a go, but honestly its a bit intimidating! What are your thoughts? |
… the before html during non-morphing renders. this is already how it is in morphing renders.
…s probably a better way to resolve this, but get the tests green for now.
…, so switch to Bardo for morphing renders as well.
23791a0
to
865dea2
Compare
I'm closing this. While it is an overall improvement, I'm running into other more fatal ramifications from the core problem of Idiomorph deleting and readding siblings during a reordering morph. I have no choice now but to try to address this directly within Idiomorph. The good news is that I have a proof-of-concept that demonstrates my desired outcome is indeed possible. I had worried that it ultimately came down to fundamental limitations of the DOM API, as described in whatwg/dom#1255 . But my PoC demonstrates that there is clear room for improvement between status-quo Idiomorph and some future Idiomorph using upcoming DOM movement APIs. Diving into the Idiomorph guts now. Wish me luck. |
Hi folks, thanks a ton for Turbo! I have been building a collaborative issue tracker app, and being able to write 99% of it in Ruby makes me smile every time. :D
Motivating use-case
However, one of the issue tracker app's primary use-cases has exposed a bug in the integration between Idiomorph and the
data-turbo-permanent
attribute. Each ticket contains adata-turbo-permanent
checkbox to keep track of the client-side state of whether or not the ticket is currently expanded for that client or not. We also allow tickets to be reordered via drag-and-drop. The issue is that thisdata-turbo-permanent
checkbox is not always preserved across morphs involving ticket reorders. There are other more serious ramifications of this bug (data loss!), but this is the simplest case to illustrate the issue.Diagnosis
I have reduced this scenario down to the failing test case in this PR. I've dug into the
DefaultIdiomorphCallbacks
integration class and into the Idiomorph code itself, and I believe the issue ultimately lies within Idiomorph, specifically here: https://github.com/bigskysoftware/idiomorph/blob/f75fba125e6e3cbfaa31dfa2af11be94455c6a38/src/idiomorph.js#L212 . In the specific reordering case captured in the test, it seems that one of the two nodes is being removed completely and then added anew with fresh DOM elements, rather than being moved and morphed. Thus, thedata-turbo-permanent
handling inDefaultIdiomorphCallbacks
is never even run. Or at least that's my assessment. I don't claim to have a full understanding of Idiomorph's internals yet! I would love another pair of eyes on this.Next steps?
Also, I'm unsure of how to proceed. On one hand this could be considered a bug in Idiomorph, for not morphing as much as it conceivably could. But on the other hand, the
data-turbo-permanent
functionality is ultimately a Turbo feature, so perhaps this is within Turbo's purview, and maybe its worth looking into integrating Idiomorph with Bardo instead to provide thedata-turbo-permanent
functionality?What are your thoughts?