I have a newly generated resource and affiliated LiveView components that are almost entirely “stock”, generated using Phoenix 1.7. What I have is a table populated by items that displays odd behavior as I’m working with the data, with table entries disappearing in the front end.
When I start it looks like this:
After I edit one of those entries using the pop-up modal what I see is this:
If I click on the flash message to make it go away, this is what I now see:
As stated this is almost entirely “stock” generated code. This is the save function in the form_component
for the Map object:
defp save_map(socket, :edit, map_params) do
case Maps.update_map(socket.assigns.map, map_params) do
{:ok, map} ->
notify_parent({:saved, map})
{:noreply,
socket
|> put_flash(:info, "Map updated successfully")
|> push_patch(to: format_url(socket.assigns.patch, map.slug))}
{:error, %Ecto.Changeset{} = changeset} ->
{:noreply, assign_form(socket, changeset)}
end
end
The handler code for the parent receiving the message is:
def handle_info({DionysusWeb.MapLive.FormComponent, {:saved, map}}, socket) do
{:noreply, stream_insert(socket, :maps, map)}
end
I have no other code modifying that stream (except for delete which isn’t being used here). This seems like fairly basic functionality so I’m wondering what exactly I’m doing wrong. Why are those table rows disappearing?