The application I’m developing has a background gradient that I noticed flashing between liveviews so I inspected the dom and was surprised to see the layout re-rendered w/ each transition to a new liveview. I’m specifying the :layout
and I’ve got a live_session
wrapping the liveviews in the router and I’m using push_navigate
to navigate between liveview. In the documentation it says live sessions keep the same layout, which it is, but I thought that would mean the layout elements was tracked and not re-rendered without changes to their props. Or am I doing something wrong?
Liveview:
@impl true
def handle_event("continue", _, socket) do
{:noreply, push_navigate(socket, to: ~p"/provider/enter-mrn")}
end
Router:
scope "/provider", ProviderWeb do
pipe_through([:browser])
live_session :provider,
layout: {ProviderWeb.Layouts, :provider},
on_mount: [{ProviderWeb.ProviderHooks, :version}] do
live("/welcome", WelcomeLive, :index)
live("/enter-mrn", MRNLive, :index)
live("/enter-dob", DOBLive, :index)
live("/orders", OrdersLive, :index)
end
end
layout:
<link phx-track-static rel="stylesheet" href={~p"/assets/provider"} />
<ProviderWeb.CoreComponents.header />
<main class="provider">
<%= @inner_content %>
</main>
<footer class="provider">
<p>
version: <%= @version %>
</p>
</footer>