srcrip / live_toast

A beautiful drop-in replacement for the Phoenix Flash system.
https://toast.src.rip
MIT License
193 stars 17 forks source link

`put_toast` do not work with `push_navigate` #11

Closed luislhsc closed 4 months ago

luislhsc commented 5 months ago

Hey, thank you for all your effort on this lib! It is awesome, very customizable and looks great.

On thing I noticed, is that it only works on my live components/view if I use push_patch

case create_thing(socket, params) do
      {:ok, thing} ->
        socket
        |> put_toast(:success, "Thing was created!")
        |> push_patch(to: ~p"/app/thing/#{thing.id}")
        |> noreply()

      {:error, changeset} ->
        socket
        |> assign(:form, to_form(changeset))
        |> noreply()
    end

If I change it to be push_navigate instead of patch:

        socket
        |> put_toast(:success, "Thing was created!")
        |> push_navigate(to: ~p"/app/thing/#{thing.id}")
        |> noreply()

The toast does not work. Is it a bug or is there a limitation to make it work with push_navigate? Just a note, the put_flash from Phoenix/Liveview works on push_patch/push_navigate/redirect.

srcrip commented 5 months ago

This seems to be the same thing noticed in https://github.com/srcrip/live_toast/issues/9... I'm going to take a look at it today. If you have a minimal repro it would help a lot though.

srcrip commented 4 months ago

ok I have a plan for how to implement this. I should have it ready in a few days.

srcrip commented 4 months ago

I'm going to close this in favor of https://github.com/srcrip/live_toast/issues/9 cause it was opened first.