CodeSync
Keynote: The Road To LiveView 1.0 by Chris McCord | ElixirConf EU 2023
Code Sync: Keynote: The Road To LiveView 1.0 by Chris McCord | ElixirConf EU 2023
Comments welcome! View the code-sync and elixirconf-eu tags for more Code Sync and ElixirConf EU talks!
Most Liked
chrismccord
When it’s ready
I gave our rundown of what we want to tackle for 1.0 in the talk, so follow the issues tracker to stay up to date. Now would be a great time to jump in!
AlchemistCamp
This was my favorite Phoenix talk in a long time. During the last 1/3 of the talk, it felt almost like Chris had seen my code and built one solution after another for each headache I’ve encountered with LiveView the past several weeks!
Is there a link anywhere to the form demo repo?
fceruti
I just spent a bunch of time going back and forward watching the video trying to implement the nested forms thing, and I got stuck trying to solve some issues. This post is about my findings.
Check out the video, it’s just ~15 sec. There are two bugs:
- After the first click “Add status” (add row), the checkbox stays selected, so when we “Add a role” (column), both a row and a column are added since both were checked. This is actually quite natural behavior, why would phoenix send updates on a static element? Actually I’m quite baffled it even worked in the demo at all.
The “Add Status” btn is similar to lines 45-48
- When I deleted row indexed 1, phoenix re indexed all the rows down, giving me a new indexed 1 checkbox and for some reason proceded to check this new index 1 checkbox (the button is similar to lines 36-39 in the picture). Then when I click to delete row 0, both row 0 & 1 are deleted. I’m not sure if this is a browser thing (tested on firefox & safari), a phoenix js thing or a morph dom thing.
What I do know now, is that all this bugs are solved IF… drum rolls please
IDs. Maybe some other attribute will work to, but ids are fine. We need something that triggers an update when we need a fresh new element, that includes a marker that helps whoever is confusing these elements.
For the elements outside inputs_for (add rows & cols), I’m using this:
n_rows = Phoenix.HTML.Form.inputs_for(form, :field_name) |> length()
...
~H"""
<input [..] id={"add-row-#{@n_rows}"} />
"""
For the inside ones, it’s simpler. LiveView’s inputs_for (different from the Phoenix.HTML.Form one), adds a very self explanatory field _persistent_id to every nested form, which can be accessed like this:
<.inputs_for :let={f_status} field={@statuses_field}>
<input type="checkbox" [...] id={"row-delete-#{f_status.id}"} />
</.inputs_for>
So, how is your weekend going? ![]()
Popular in Talks
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










