petalframework / petal_components

Phoenix + Live View HEEX Components
https://petal.build/components
MIT License
767 stars 84 forks source link

Table with stream clears upon update #294

Open storkweb opened 5 months ago

storkweb commented 5 months ago

Hi, Trying the Table component (v 1.9.0) but it clears all shown values upon update (yes I put the phx-update="stream" that's missing from the example). it seems that the <:col> has no id but how can I specify the field from the stream in the table's row_id ?

Thanks

mplatts commented 5 months ago

hmm. did you try the row_id attribute? Looks like I need to update the doc.

<.table
  id="users"
  rows={@streams.users}
  row_click={fn {_id, user} -> JS.navigate(~p"/users/#{user}") end}
  row_id={fn {_id, user} -> "user--#{user.id}" end}
>

Here is the code: https://github.com/petalframework/petal_components/blob/main/lib/petal_components/table.ex

I used the phx generator as a base and adapted it to Petal.