-
Notifications
You must be signed in to change notification settings - Fork 915
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
Bug : Liveview dynamics with nil values when using nested loops #529
Comments
If I add in the handle_event a new value for
It seems that when If %Phoenix.LiveView.Rendered{
|
Here is the value for
It seems that since in the inner loop,
My temporary fix is to have the function |
If I add this test in engine_test.exs
If But this test fails :
|
Similar problem. Have a list of "items". Each contains a "metadata" map. Outer loop always renders fine. Inner loop renders fine for first render. Mutations cause the inner loop to always return null. |
If you look at https://elixirforum.com/t/problem-with-liveview-sending-diff-with-null-values/27507/5, I gave 2 ways to make it work. |
I just faced this issue as well. It seems that this issue started from this commit: 57f2ef7 For the time being, we can set our mix to get Phoenix Live View from this specific commit: {:phoenix_live_view, github: "phoenixframework/phoenix_live_view", ref: "ba6d17bbaaccf6981ed859697329d7cfe2484f71"}, |
I've been trying to find out the solution but I'm kinda lost in how to debug the AST generated by the old code vs the one generated by the new code, I can see they have differences but I cannot point out where and why 🙈 This is the test I believe reproduces this issue. At least it pass when I run it in ba6d17b. test "nested for comprehensions" do
template = "<%= for foo <- @foo do %><%= for bar <- foo.bar do %><%= foo.x %><%= bar.y %><% end %><% end %>"
assert [
%{
dynamics: [
[%{dynamics: [["1", "1"]], static: ["", "", ""]}]
],
static: ["", ""]
}
] = changed(template, %{foo: [%{x: 1, bar: [%{y: 1}]}]}, %{foo: true})
end Hope it helps find the issue cc @josevalim |
Thanks @feliperenan for pinging me! The sample to reproduce the issue helped a lot! A fix was pushed! |
Environment
Actual behavior
If we have
If
rows
gets a new value andcols
doesn't get a new value Liveview returns this diffdynamics: [[nil], [nil]]
I first explained the problem on https://elixirforum.com/t/problem-with-liveview-sending-diff-with-null-values/27507/5
When I use this template https://gist.github.com/imartinat/da1707a3c7e4681e6e1d8c31179b6ce4
Liveview doesn't work and sends a diff with null values. The first render works fine but when I click on “Replace users”, the diff sent by Liveview contains:
Expected behavior
Liveview works fine and updates the list of users if I replace:
BY
It was working fine on a previous version of Liveview.
The text was updated successfully, but these errors were encountered: