However when using live_redirect, the sidebar template is not re-rendered when a new LiveView is routed to. I’m wondering how to solve it.
I’ve tried to use live_render inside the root layout to render a SideBar LiveView. Doesn’t work as handle_params can’t be called since this isn’t the “main” liveview.
Any pointers how to separate my side bar that uses live_redirect for the links without tying it up with all my other content LiveViews?
It works if I use a normal redirect (as the page is rerendered), but this will tear down the LiveView socket.
You can assign a menu variable inside your liveviews that you can also pass to the logic holding your menu (be it a live_view, live_component or even a simple template). But you will need to move it from your root layout inside your live layout.
Create a new module to assign “current_uri” to your socket. I only set the path string to the assigns, since I don’t want/need the whole URI enchilada.