Browsers you attempted to reproduce this bug on (the more the merrier):
Does the problem persist after removing "assets/node_modules" and trying again? Yes/no: Yes
Actual behavior
In my application, i use nested liveview in layout to implement sidebar. In sidevar liveview, using <.link navigate> navgite to liveview is ok, but using push_navigate in click handle_event cause full reload, and liveview socket is reconnected.
app.html.heex implement sidebar as nested liveview in layout
navigate by click event, call push_naviagte in handle_event callback cause liveview reconnect
defmodule TestliveWeb.SideBarLive do
use TestliveWeb, :live_view
def render(assigns) do
~H"""
<div class="flex flex-col">
<span>sidebar</span>
<.link navigate={~p"/articles/2/show"}>article2_link_navigate</.link>
<a phx-click="nav_to_article" phx-value-id="2">article2_push_navigate</a>
</div>
"""
end
def handle_event("nav_to_article", %{"id" => id}, socket) do
{:noreply, socket |> push_navigate(to: ~p"/articles/#{id}/show")}
end
end
article_live.ex
defmodule TestliveWeb.ArticleLive do
use TestliveWeb, :live_view
@impl true
def render(assigns) do
~H"""
<div>
<%= @id %>
</div>
"""
end
@impl true
def mount(%{"id" => id}, _session, socket) do
{:ok, assign(socket, id: id)}
end
end
main_live.ex
defmodule TestliveWeb.MainLive do
use TestliveWeb, :live_view
@impl true
def render(assigns) do
~H"""
<div>
<.link navigate={~p"/articles/1/show"}>article1</.link>
</div>
"""
end
end
router
scope "/", TestliveWeb do
pipe_through :browser
live "/main", MainLive, :index
live "/articles/:id/show", ArticleLive
end
Expected behavior
use push_naviagte in nested liveview don't causes full reload
Environment
Actual behavior
In my application, i use nested liveview in layout to implement sidebar. In sidevar liveview, using <.link navigate> navgite to liveview is ok, but using push_navigate in click handle_event cause full reload, and liveview socket is reconnected.
app.html.heex implement sidebar as nested liveview in layout
side_bar_live.ex
navigate by click event, call push_naviagte in handle_event callback cause liveview reconnect
article_live.ex
main_live.ex
router
Expected behavior