I run into a problem where a liveview set in root layout won’t update when I use push_redirect. You can see the minimal example of it in this github repo, relevant files being revealed in this commit (Bug · asprecic/elixir-buggy-sidebar@74c7150 · GitHub) - [root.html.heex, live/Bug.ex and live/Sidebar.ex]
GitHub - asprecic/elixir-buggy-sidebar: Possible bug with phoenix
Basically, the liveview rendered inside the root layout doesn’t update because of push_redirect. If you remove the push_redirect, then it will update the view.
The odd thing here is that if you look at the network traffic or enable debugging in app.js, you will see that the diff is done correctly, the update comes over the network, it is logged correctly in the console, but it never gets applied to the DOM. Sometimes it does get applied, sometimes not, I can’t reliably tell when.
I know I can fix this problem by moving the sidebar into live.html.heex, which will remount it when redirecting, but I’m interested as to why this is not working? In theory, it should, and in practice, we get the good diff, but it’s just not being applied, leading me to believe this might be a liveview bug?
Can someone shed more light on this issue? Is this a problem with liveview itself, or am I doing something wrong or expecting too much from a redirect?
Screenshot: https://i.imgur.com/YJbOw6S.png
Thanks!