phoenix_live_view changelog


Hey there, awesome developers! 🎉 We've got some exciting updates and fixes rolled out for you. Dive into the latest changes and see how they can make your coding journey smoother and more fun! 🚀

  • New feature: Omit Name for Colocated JS
    You asked, and we delivered! Now, in the Phoenix.LiveView.ColocatedJS module, you can skip specifying a name for your colocated JavaScript files if they're just for side effects. This means less clutter and more streamlined code. Just remember, if you're using a key, you'll still need that name. We’ve also updated our test suite to make sure everything runs smoothly. 🎉

  • Bugfix: Variable Tainting Issue
    We've squashed a bug that was causing some form fields not to update when their changeset was modified. A missing analyze call was the culprit, but it's all fixed now! Your forms should re-render like a charm, reflecting any changes in real-time. We've also added some tests to ensure everything is in tip-top shape. 🛠️

  • Improvement: Custom Error for Duplicate IDs
    Running into duplicate IDs with keyed comprehensions? We've got you covered with a new, more descriptive error message. Now, you'll get detailed info about where the duplication occurs, making debugging a breeze. We've also added a test case to keep things robust and reliable. 🕵️‍♂️

  • Bugfix: Fix for Live Components Error Handling
    Our Phoenix.LiveView.Debug.live_components function is now better at handling invalid PIDs. We've switched to catching :exit signals, ensuring you get a clear error message when something's amiss. Plus, there's a new test to make sure everything's working as it should. 🎯

  • Improvement: Documentation Update
    We've tweaked the syncing changes guide to update a Topbar library method. Instead of topbar.delayedShow(500), it's now topbar.show(500). This ensures your Topbar pops up immediately during page loads. Just a little change for a smoother experience! 📚

Happy coding, and keep those awesome projects coming! 💻✨

Included Commits

2025-06-20T12:23:55 See commit

The commit titled "fix variable tainting (#3856)" addresses an issue in the Phoenix LiveView framework where a missing analyze call could prevent certain components from re-rendering when their underlying data changes. Specifically, it resolves a problem where a form's field value would not update in the UI when the associated changeset was modified. The fix involves modifying the code in lib/phoenix_live_view/engine.ex to include an analyze function call, which ensures that the rendering engine properly tracks changes to variables and triggers re-renders as necessary.

Additionally, the commit includes updates to the test suite in test/phoenix_live_view/diff_test.exs, introducing new tests that verify the correct behavior of the :let syntax in conjunction with form data access. These tests ensure that when the form's data changes, the UI reflects those changes accurately, thereby confirming that the fix successfully addresses the original issue of variable tainting and re-rendering behavior. Overall, the changes enhance the reliability of the LiveView framework in managing dynamic content updates.

Files changed

  • lib/phoenix_live_view/engine.ex
  • test/phoenix_live_view/diff_test.exs
2025-06-24T10:40:52 See commit

The commit introduces a feature in the Phoenix.LiveView.ColocatedJS module that allows developers to omit the name attribute for colocated JavaScript files. Previously, specifying a name was mandatory even if the script was intended for side effects only. With this change, if the name is omitted, the script will be imported solely for side effects, streamlining the process for scripts that do not require exports. However, if a key is provided, a name remains necessary, ensuring that the export structure is maintained.

Additionally, the commit includes updates to the test suite to verify the new functionality. A new test case checks that a nameless script is correctly imported for side effects, confirming that the generated JavaScript behaves as expected. The overall modifications consist of 26 additions and 15 deletions across the codebase, enhancing the flexibility of colocated JavaScript integration in Phoenix LiveView applications.

Files changed

  • lib/phoenix_live_view/colocated_js.ex
  • test/phoenix_live_view/colocated_js_test.exs
2025-06-24T11:12:59 See commit

This commit addresses an issue in the Phoenix.LiveView.Debug module where the live_components function was not correctly handling cases where the provided process ID (PID) did not correspond to a LiveView process. The fix involves changing the error handling from a rescue block to a catch block, specifically catching :exit signals, which allows the function to return an appropriate error tuple {:error, :not_alive_or_not_a_liveview} when the PID is invalid.

Additionally, the commit includes the addition of a test case in the debug_test.exs file to verify the functionality of the live_components method, ensuring that it correctly returns the error when a non-LiveView PID is passed. This enhances the robustness of the LiveView debugging capabilities by providing clearer error handling and validation.

Files changed

  • lib/phoenix_live_view/debug.ex
  • test/phoenix_live_view/debug_test.exs
2025-06-24T11:13:24 See commit

This commit introduces a custom error handling mechanism for duplicate IDs encountered during the use of keyed comprehensions in the Phoenix framework. Specifically, it raises a more descriptive error when a duplicate key is detected, providing details about the key's context, including the module, line, and column where the duplication occurs. This enhancement aims to improve debugging by making it clearer to developers when they are dealing with conflicts in keyed comprehensions.

In addition to the error handling changes, the commit also includes updates to the test suite to verify the new functionality. A test case has been added to ensure that rendering a template with duplicate keys raises the appropriate error message. Overall, these modifications enhance the robustness of the Phoenix LiveView component system by addressing potential issues with ID uniqueness in a more informative way.

Files changed

  • lib/phoenix_component.ex
  • lib/phoenix_live_view/diff.ex
  • lib/phoenix_live_view/tag_engine.ex
  • test/phoenix_live_view/diff_test.exs
2025-06-24T19:09:22 See commit

The commit titled "Update syncing-changes.md (#3862)" modifies the documentation for the syncing changes in the client guides. It specifically updates a code snippet related to the usage of the Topbar library, changing the method from topbar.delayedShow(500) to topbar.show(500) in the context of handling page loading events in a JavaScript application.

This change reflects a correction in the implementation, ensuring that the Topbar displays immediately when a page loading event starts, rather than with a delay. The commit includes minor modifications to the documentation file, with one line added, one line deleted, and two lines changed to accurately represent the updated code functionality.

Files changed

  • guides/client/syncing-changes.md