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

Fix issue with new elements in stream DOM test #2677

Merged

Conversation

danschultzer
Copy link
Contributor

@danschultzer danschultzer commented Jun 8, 2023

I encountered this issue testing pagination with stream resets. Going to next page the first time worked, but subsequent stream resets failed (though it worked just fine in the browser).

This is due to the container id check. New items don't have any parent because the id would be unique. It just skips the element entirely, thus not setting the data-phx-stream value. It works the first time because the DOM already has the first list with ids.

The simplest fix I could think of was just to ignore if parent_id is nil (this means new unique item), but not sure I like this because what happens if you have multiple lists? Wouldn't it just update all lists? I couldn't grok how this is dealt with in JS, so I'm leaving it for now.

This resolves an issue for testing streams. New items didn't get assigned the data-phx-stream and thus subsequent stream resets didn't reset the list as the previously added items couldn't be matched for the data-phx-stream.
@nmk
Copy link
Contributor

nmk commented Oct 20, 2023

@chrismccord, @josevalim Could we have this one merged? I can confirm that it fixes the problem (and the follow up) I described in #2629 (comment).

@chrismccord chrismccord merged commit db964c5 into phoenixframework:main Dec 18, 2023
@chrismccord
Copy link
Member

❤️❤️❤️🐥🔥

@danschultzer danschultzer deleted the fix-stream-dom-test-issue branch December 18, 2023 19:37
SteffenDE pushed a commit to SteffenDE/phoenix_live_view that referenced this pull request Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants