-
Notifications
You must be signed in to change notification settings - Fork 948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sticky liveview can't handle event after calling push_navigate #3612
Comments
I pulled the sample and played around with it a bit. It sounds like the Removing the Is there a use case for using Also, as a side note, a live view for navigation might be overkill compared to just a normal phoenix component (though I realize there is probably missing context here). |
@chrismccord I don't think we currently expect sticky LiveViews to use push_navigate. The sticky LiveView shuts down for navigation, but the client never reconnects. I'm not 100% sure what the correct behavior here should be. We could either not shutdown sticky LiveViews on the server, or ensure that we reconnect on the client. @limeuser you can use "normal" links instead for now diff --git a/lib/test_web/live/sidebar_live.ex b/lib/test_web/live/sidebar_live.ex
index 09e9ec0..5c76157 100644
--- a/lib/test_web/live/sidebar_live.ex
+++ b/lib/test_web/live/sidebar_live.ex
@@ -8,8 +8,8 @@ defmodule TestWeb.SidebarLive do
~H"""
<div>side bar</div>
<div class="flex flex-col">
- <a href="#" phx-click="nav_to_article" phx-value-article_id="1" class="block">article1</a>
- <a href="#" phx-click="nav_to_article" phx-value-article_id="2" class="block">article2</a>
+ <.link navigate={~p"/articles/1"} class="block">article1</.link>
+ <.link navigate={~p"/articles/2"} class="block">article2</.link>
</div>
"""
end As @TylerWitt said, a LiveView for a navbar might be overkill, but that of course depends on the context. In most LV apps I worked with, navigation was handled as function component in the layout and we had a special "@current_route" assign that each LiveView was required to set to mark the active route. |
|
Why the sticky LV shuts down for navigation, and the client never reconnects? The sticky LV must keep it's status, and maybe update it's status when navigating, so i can't understand the design. |
The browser would do this for you with normal links, assuming that you are keeping the current section/breadcrumb in the path. |
I mean the sticky navbar LV contains a live component, it need to call send_update(cid, assigns) to update the live component when navigating to another article LV. |
Environment
Actual behavior
i have a sticky side bar live view, it is a tree view to navigate to article live view.
reproduce the bug: https://github.com/limeuser/test.git
Expected behavior
sticky live view can handle client events.
The text was updated successfully, but these errors were encountered: