Phoenix stream reset woes

I’m having a bad time here and just posting to see if anyone can see what I’m doing wrong.

I’m using Flop Phoenix with streams. When I go to sort fields by clicking the header, the URL updates properly but nothing re-renders. Refreshing the page gives the desired results, so I figure there is nothing wrong with my business code. I’ve set it up according to the docs and no matter what I do, nothing seems to work. I’ve tried simplifying the table, configuring the stream with a different id function, and ore or less randomly changing the order of things, adding a mount function, removing the table opts, and so on. I’m sort of at my wit’s end for now so going to walk away for a bit, but I wanted to post here just in case someone can see what I’m doing wrong. I’m assuming it’s something really stupid.

Thanks in advance (and no problem if no one wants to help, lol).

Here is my whole liveview minus event handlers:

defmodule DesjWeb.Admin.Requests.IndexLive do
  @moduledoc false
  use DesjWeb, :live_view

  @impl true
  def handle_params(params, _uri, socket) do
    case Desj.Requests.list_open_requests(params) do
      {:ok, {requests, meta}} ->
        socket =
          |> stream(:requests, requests, reset: true)
          |> assign(:meta, meta)

        {:noreply, socket}

      {:error, _meta} ->
        {:noreply, push_navigate(socket, to: ~p"/admin/requests")}

  @impl true
  def render(assigns) do
    <div :if={@meta.total_count == 0}>
      There are no requests at this time.

      :if={@meta.total_count > 0}
      opts={flop_table_opts(image?: true)}
      <:col :let={{_, request}}>
        <.artwork artwork={request.artwork} />
      <:col :let={{_, request}} label="Artwork" field={:artwork_title}>
        <%= request.artwork.title %>
      <:col :let={{_, request}} label="User" field={:user_name}>
        <%= %>
      <:col :let={{_, request}} label="Exclusivity?" field={:request_exclusivity}>
        <%= request.request_exclusivity %>
      <:col :let={{_, request}}>
        <div :if={request.status == :open} class="flex items-center gap-2">
          <form id={"reject-form-#{}"} phx-submit="REJECT">
            <input type="hidden" name="request_id" value={} />
            <.button kind={:reject}>Reject</.button>

          <form id={"accept-form-#{}"} phx-submit="ACCEPT">
            <input type="hidden" name="request_id" value={} />
            <.button kind={:go}>Accept</.button>

            :if={request.status == :rejected}
            <input type="hidden" name="request_id" value={} /> Rejected

It should be fixed on main. See Regression in 0.20 when resetting a stream that contains the same values, but reordered. · Issue #2826 · phoenixframework/phoenix_live_view · GitHub for more info.


Ohhhhh, thanks! I thought I was losing my mind. I found a few issues but they were old so assumed it wasn’t a thing anymore.


PS: I’m aware I have some bare <form>s (it’s on the list)… no one reading this should take that as good style :upside_down_face:

1 Like