We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
phoenix_live_view changelog
Hey there, awesome developers! 🎉 We've got some cool updates and fixes here for the Phoenix LiveView framework. Let's dive into the latest changes and improvements that'll make your coding life a tad bit easier!
-
New feature: We've introduced tests for handling file uploads within nested LiveViews! This enhancement focuses on making sure uploads work smoothly even in complex nested structures. The
UploadChannelTest
module has been updated to include a new nested LiveView,NestedUploadLive
, which is all about testing uploads in more intricate scenarios. This change is a big win for improving the robustness of the upload feature in nested situations. 🚀 -
Improvement: A new change ensures that stream elements are forcibly removed during a join patch operation. This update enhances stream management, especially when dealing with nested components. The method now checks ownership before removing elements, making sure your streams are as tidy as your codebase! 🌊
-
Improvement: The
refute_redirected
function got a little more flexible! Now, it can refute any redirection, not just specific paths. This makes testing even more comprehensive, allowing you to assert that no redirection occurs at all for a given view. 💪 -
Bugfix: We've tackled an issue with the
_target
parameter being decoded too early. The fix ensures that decoding happens at the right time, making sure your form values are accurately processed. This resolves a pesky bug and keeps things running smoothly. 🐛 -
Bugfix: Another fix ensures the
_target
parameter is sent as"undefined"
when it doesn't exist. This maintains backward compatibility with older versions, even if it feels a bit quirky. But hey, it works! 🤷♂️ -
Bugfix: The
sync_with_root
function in theClientProxy
module has been patched up to ensure the correct root view's PID is used during the ping operation. This little tweak enhances the reliability of syncing between child and root views. 🔄
These updates are here to make your life easier and your applications more robust. Keep on coding and enjoy the ride! 🎈
Included Commits
This commit addresses a decoding issue with the _target
parameter in the Phoenix LiveView framework, specifically correcting the timing of its decoding. Following a previous change in commit #3688, the _target
parameter was being decoded prematurely during the merging of extra values into the form values. The fix ensures that the decoding occurs at the correct stage, which resolves an associated issue documented as #3719.
In addition to the code modifications in lib/phoenix_live_view/channel.ex
, the commit introduces a new test case in test/e2e/support/issues/issue_3719.ex
to verify that the _target
parameter is now correctly handled. The test checks the behavior of a LiveView when interacting with form inputs, ensuring that the target value is accurately reflected in the rendered output. This enhancement is further validated by a new end-to-end test in test/e2e/tests/issues/3719.spec.js
, which confirms that the application does not crash and that the expected values are displayed correctly after user interactions.
Files changed
- lib/phoenix_live_view/channel.ex
- test/e2e/support/issues/issue_3719.ex
- test/e2e/test_helper.exs
- test/e2e/tests/issues/3719.spec.js
This commit addresses an issue related to the handling of the _target
parameter in the Phoenix LiveView framework, specifically ensuring that it is sent as the string "undefined"
when it does not exist. In previous versions (up to 1.0.5), _target
was included in the URL encoded form values. However, with the update to version 1.0.6, the framework transitioned to sending metadata directly in the form event, which caused keys with undefined values to be omitted in the JSON encoding process. To maintain backward compatibility, the commit restores the behavior of sending _target
as "undefined"
when it is not defined, despite acknowledging that this approach may not be ideal.
The changes made in this commit include modifications to the view.js
file, where the _target
is now explicitly set to either the provided value or the string "undefined"
if it is absent. Additionally, the commit enhances the test suite to verify that the _target
is correctly included in the payload sent during form submissions, particularly when dealing with nameless inputs. This ensures that the behavior remains consistent with earlier versions while adapting to the new event handling structure.
Files changed
- assets/js/phoenix_live_view/view.js
- assets/test/view_test.js
The commit titled "Force remove stream elements on join patch" introduces a modification to the DOMPatch
class in the phoenix_live_view
library, ensuring that stream elements are forcibly removed during a join patch operation. The changes include an updated method that filters stream elements based on ownership before removal, addressing issues with nested streams where parent elements might be removed before their children. This is achieved by adding an optional force
parameter to the removeStreamChildElement
method, allowing for the enforced removal of elements even if they are not owned by the current view.
Additionally, the commit includes implicit tests to verify the new behavior and introduces a new helper function, remove_stream_children
, which clears out stream children from the HTML tree. This function is integrated into the test suite, ensuring that the expected behavior is maintained in various scenarios, particularly when dealing with nested components. Overall, the changes aim to enhance the robustness of stream management within the LiveView framework, especially in complex rendering situations.
Files changed
- assets/js/phoenix_live_view/dom_patch.js
- lib/phoenix_live_view/test/client_proxy.ex
- lib/phoenix_live_view/test/dom.ex
- test/support/live_views/streams.ex
This commit enhances the functionality of the refute_redirected
function in the Phoenix LiveView testing framework. Previously, this function was limited to refuting specific redirection paths. The update introduces an overload of the refute_redirected
function that allows it to refute any redirection when no specific path is provided. This change improves the flexibility of testing by enabling developers to assert that no redirection occurs at all for a given view.
Additionally, the commit includes corresponding updates to the integration tests, ensuring that the new functionality is properly validated. The tests confirm that when a view is expected not to redirect, any unexpected redirection triggers an ArgumentError
, complete with a detailed message. Overall, this commit enhances the robustness of the testing framework by allowing for more comprehensive assertions regarding navigation behavior in LiveView applications.
Files changed
- lib/phoenix_live_view/test/live_view_test.ex
- test/phoenix_live_view/integrations/nested_test.exs
This commit addresses an issue in the sync_with_root
function of the ClientProxy
module in the Phoenix LiveView test suite, specifically targeting the handling of pinging root views. The change modifies the logic to ensure that when a child view is targeted, the correct root view's process identifier (PID) is used for the ping operation.
The update involves a simple yet crucial adjustment in the code, replacing the reference to view.root_pid
with state.root_view.pid
. This change enhances the reliability of the synchronization process between child and root views by ensuring that the correct root view is pinged, thereby resolving the issue documented in issue #3732.
Files changed
- lib/phoenix_live_view/test/client_proxy.ex
This commit introduces tests for handling file uploads within nested LiveViews in the Phoenix framework, specifically addressing an issue documented in the GitHub repository. It modifies the UploadChannelTest
module to include a new nested LiveView, NestedUploadLive
, which allows for the testing of upload functionality in a more complex LiveView structure. The commit adds a function to mount this nested LiveView and sets up the necessary conditions for testing uploads, enhancing the robustness of the upload feature in nested scenarios.
Additionally, the commit updates the UploadLive
module to accommodate a session prefix for better identification of nested components. It also includes the definition of the new NestedUploadLive
module, which renders the existing UploadLive
component within its context. Overall, these changes improve the testing capabilities of the Phoenix LiveView framework by ensuring that nested uploads are handled correctly, thereby addressing the related GitHub issue and enhancing the overall functionality of LiveView uploads.
Files changed
- test/phoenix_live_view/upload/channel_test.exs
- test/support/live_views/upload_live.ex