kminevskiy
Hey folks,
Does anyone know what could cause the following behavior: I have a live view template and in it I conditionally render a form (based on the value inside the socket assigns).
<%= if length(@users) > 0 do %>
...
<% end %>
When the length changes, it used to render a form, but now nothing happens. If I prepend that first line with, say, a tag <p><%= length(@users) %></p> Everything (showing the form dynamically based on the length of @users list) works as expected. I am pretty sure the code worked as is a few weeks ago before I updated to the latest Live View (but I’m not even sure it’s an issue with Live View), among other packages. Am I missing some new behavior introduced recently or is there something else I’m not doing correctly?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 18 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
PJUllrich
This might not help in this particular case, but I recently learned that a template gets rendered and send over the websocket connection every time the socket assigns are changed when it isn’t in the .leex format, so when it is a .eex file. Just changing all file formats to .leex reduced the websocket traffic by a lot! So, whenever you do
<%= render "my_template.html", assigns %>inside a template, make sure thatmy_templateis of the format .leexkminevskiy
Interesting. Do you know / remember if that was the behavior specific to a certain (earlier) release of LiveView? As I mentioned above, I haven’t had any issues with 0.10.0, but after upgrading to 0.11 (and then to 0.12.x) I encountered the aforementioned issue.
carterbryden
I had a similar issue with conditional rendering with liveview. I posted an issue but I just haven’t had enough time to create a reproduction repo publically (client project). In my case it seemed like it might be related to a nested liveview inside a conditional in a liveview template. Still don’t have a fix for it, I just changed the way I was rendering things to work around needing the if statement. I’ll post here if I do figure it out.
kminevskiy
A quick update: it doesn’t look like I can reproduce this bug (?) on a new installation. I suppose it’s specific to my project and I’ll have to debug on my own. I’ll post the solution in this thread.
kminevskiy
Will be happy to. Let me extract that portion and I’ll create an issue. Thank you!
axelson
Hmm, in that case it seems like it would be worthwhile to provide a reproduction project and post an issue to the project.
kminevskiy
Unfortunately, that didn’t help.
If I add
<p><%= Enum.any?(@users) %></p>above the conditional, everything works as expected (firstfalseis being rendered and then, once an event happens, it switches totrueand the form inside the conditional is rendered).So far, I’ve checked the following:
renderfunction receives pre-computed value (it’s not calculating it on the fly).IO.inspect/1actually renders the list correctly.Let me know if there’s anything else I could try.
axelson
It looks like 0.12.1 isn’t actually released on hex yet. But please report back when you try a version with the fix!
kminevskiy
I was looking at that fix a few minutes ago. I’ll update to 0.12.1 and report back.
axelson
Maybe you could try the master branch. I encountered a fairly similar problem with content disappearing that Chris McCord has fixed on the master branch. I think it is this changelog entry: “Fix component innerHTML being discarded when a sibling DOM element appears above it, in cases where the component lacks a DOM id”