phoenix_live_view changelog


Hey there, Phoenix LiveView enthusiasts! We've got some cool updates and fixes to share with you, so grab a cup of coffee and dive in with us. 🚀

  • Bugfix: phx-trigger-action check for cloned tree
    We've squashed a pesky bug related to the phx-trigger-action! Now, the isNowTriggerFormExternal method does a double-check: ensuring forms are part of the document body and have the phx-trigger-external attribute. This means no more false positives when deciding if a form should trigger an external action. Plus, forms marked for external triggering are now handled like a pro during morphing. 🎉

  • Improvement: Changelog Updates
    Our changelog got a makeover! It now highlights essential fixes like cutting down on unnecessary compile-time dependencies and stopping those annoying crashes when testing LiveViews with XML. We've also made sure phx-trigger-action doesn't mess with locked forms. And there are some sweet enhancements like deduplication in stream/4 functions and better map key tracking. All these tweaks make your LiveView experience smoother than ever! 📝

  • Improvement: Change-track non-existing keys in maps
    We've optimized how templates handle non-existent map keys. If a key is missing before and after a change, no re-rendering will be triggered. This means fewer unnecessary updates and a performance boost. We've got tests in place to ensure this works like a charm. ⚡

  • Improvement: Asset Updates
    Our JavaScript files got some love, too! The isNowTriggerFormExternal function is now smarter, and we've introduced externalFormTriggered to track external form triggers during DOM patching. These updates make sure external forms get the VIP treatment they deserve. 🎨

  • Bugfix: No more compile-time deps when expanding literals
    We've tackled the issue of unwanted compile-time dependencies when expanding literals. By tweaking how Macro.expand_literals is called, we've ensured smoother macro processing in the Phoenix framework. Say goodbye to unnecessary compile-time references! 🛠️

That's all for now! Keep those LiveViews lively and stay tuned for more updates. 🌟

Included Commits

2024-12-21T18:22:25 See commit

This commit addresses the issue of generating compile-time dependencies when expanding literals in the Phoenix framework, specifically within the attr, on_mount, and live macros of the Phoenix.Component, Phoenix.LiveView, and Phoenix.LiveView.Router modules. The changes involve modifying the way Macro.expand_literals is called by replacing the __CALLER__ argument with a modified version that includes the current function context. This adjustment ensures that the macros can correctly handle the dependencies without generating unnecessary compile-time references.

By implementing these changes, the commit resolves issue #3592 and enhances the functionality of the macros by providing a clearer context during literal expansion. The modifications include updates to the handling of attributes, mount callbacks, and live sessions, ultimately leading to more efficient macro processing within the Phoenix framework.

Files changed

  • lib/phoenix_component.ex
  • lib/phoenix_live_view.ex
  • lib/phoenix_live_view/router.ex
2024-12-26T14:47:34 See commit

This commit addresses issue #3591 in the Phoenix LiveView framework by enhancing the functionality of the isNowTriggerFormExternal method in the DOM management code. The change ensures that the method not only checks for the presence of a specific attribute (phx-trigger-external) but also verifies that the element is currently part of the document body. This prevents false positives when determining whether a form should trigger an external action.

Additionally, the commit modifies the DOMPatch class to handle the submission of forms that are marked for external triggering. If such a form is detected during the morphing process, the live socket is unloaded, and the form is submitted programmatically using the prototype's submit method. This change is complemented by tests that validate the updated behavior of the isNowTriggerFormExternal function, ensuring it correctly identifies forms based on their presence in the DOM and the relevant attribute.

Files changed

  • assets/js/phoenix_live_view/dom.js
  • assets/js/phoenix_live_view/dom_patch.js
  • assets/test/dom_test.js
2024-12-26T14:48:00 See commit

This commit updates several JavaScript files related to the Phoenix LiveView framework, specifically modifying the handling of external form triggers in the DOM. The main change involves enhancing the isNowTriggerFormExternal function to check not only for the presence of a specific attribute but also to ensure that the element is contained within the document body. Additionally, a new variable externalFormTriggered is introduced to track if an external form trigger has occurred during the DOM patching process. If such a trigger is detected, the live socket is unloaded, and the form is submitted programmatically.

Overall, these modifications aim to improve the robustness of the LiveView's interaction with external forms, ensuring that elements are correctly identified and handled during updates. The changes are reflected across multiple files, including the CommonJS, ESM, and minified versions of the LiveView JavaScript, indicating a comprehensive update to the framework's client-side behavior.

Files changed

  • priv/static/phoenix_live_view.cjs.js
  • priv/static/phoenix_live_view.cjs.js.map
  • priv/static/phoenix_live_view.esm.js
  • priv/static/phoenix_live_view.esm.js.map
  • priv/static/phoenix_live_view.js
  • priv/static/phoenix_live_view.min.js
2024-12-26T14:48:48 See commit

This commit addresses an issue in the Phoenix LiveView framework related to the re-rendering of templates when accessing non-existent keys in maps. Specifically, it modifies the logic in the recur_changed_assign function to ensure that if a key does not exist in the map both before and after a change, the associated template will not trigger a re-render. This enhancement is particularly important for optimizing performance by preventing unnecessary updates in the UI.

Additionally, the commit includes new tests to validate this behavior, ensuring that when a template accesses a non-existent key (like :baz in the provided example), it will return a default value without causing a re-render if the key remains absent after an update. The tests confirm that the system behaves as expected for various scenarios, thereby improving the reliability and efficiency of the LiveView component rendering process.

Files changed

  • lib/phoenix_live_view/engine.ex
  • test/phoenix_live_view/engine_test.exs
2024-12-26T14:53:03 See commit

This commit updates the CHANGELOG.md for the Phoenix LiveView project, reflecting several important fixes and enhancements made to the framework. Notable fixes include addressing unnecessary compile-time dependencies related to the attr, on_mount, and live functions, resolving crashes when testing LiveViews with embedded XML like SVGs, and eliminating type warnings associated with the follow_redirect function. Additionally, it introduces a fix to prevent phx-trigger-action from interfering with locked forms.

The commit also highlights enhancements such as deduplicating items in the stream/4 and stream_insert/4 functions, restoring scroll position during initial navigation, and improving the tracking of non-existing keys in maps. These updates contribute to the overall stability and functionality of the Phoenix LiveView framework, ensuring a smoother development experience for users.

Files changed

  • CHANGELOG.md