phoenix_html 3.3 is breaking live_patch links
nicolasblanco opened this issue · comments
Hello,
I updated a Phoenix 1.6 & LiveView 0.17 web application from phoenix_html
3.2 to 3.3 and discovered that it was breaking all the live patch links of my application. Basically when clicking on a live patch link, the browser is just reloading the whole page (and remounting the live view) instead of just soft patching the view.
Reverting to phoenix_html
3.2 fixed the issue.
Right now I did not have the time to investigate this issue more and I don't know if it's just related to LV 0.17 or some other dependency.
Thanks!
A quick glance at live_patch
shows me it should work the same. Can you compare the generated HTML in both versions and let us know if they differ and how?
Yes, I confirm that the generated HTML of the link is the same between 3.2 and 3.3, the HTML of my links are looking like that:
<a data-phx-link="patch" data-phx-link-state="push" href="/stocks/TTE.PA" id="stock-link-c055b87d-6771-4a9a-8633-2eff3bbefa20">
..........
</a>
I see that they are changes in the small JS snippet between 3.2 and 3.3 https://github.com/phoenixframework/phoenix_html/blob/master/priv/static/phoenix_html.js
How could I check if this issue is caused by the JS?
Thanks!
I've made a diff between the whole HTML of the page between 3.2 and 3.3.
The only difference I can see is this one on data-phx-main
attribute on the LV container :
On 3.2:
<div data-phx-main="true" data-phx-session="..." ...
On 3.3:
<div data-phx-main data-phx-session="..." ...
Yes, that difference should be fine and we accounted for it. I upgraded Livebook to Phoenix.HTML v3.3 and all of the live_patch
works. So it may be something specific to your app. Please try to isolate the error.
LiveView 0.18 changed to hasAttribute
instead of getAttribute
, so you need to bump LV. Thanks!
LiveView 0.17.13 has also been published with the above fix