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! Here's the latest and greatest from our recent commits. We've packed in some handy new features, improvements, and bug fixes to make your coding life even smoother. ๐
New feature
- Validate Slot Options: ๐ Now, if you make a typo when defining slot options (like
requird
instead ofrequired
), you'll get a compile-time warning! Only the options:required
,:doc
, and:validate_attrs
are accepted. This nifty feature helps catch errors early and keeps your code clean and robust.
Improvement
-
Enhanced
clear_flash/1-2
Docs: ๐ We've added info about thelv:clear-flash
event to theclear_flash/1
andclear_flash/2
documentation. Now you can see how to clear flash messages on the client side using LiveView, complete with practical examples. -
Updated Navigation Terminology: ๐บ๏ธ All references to 'live_redirect' have been replaced with 'push_navigate' in our docs. This update standardizes terminology and ensures you're up-to-date with the latest naming conventions.
-
Fixed Callback and Function Links: ๐ We've corrected several documentation issues, particularly the references to
mount/3
, now properly noted asc:mount/3
. We've also clarified the usage of theattach_hook
function, making sure it's clear and accurate.
Bugfix
- Click Event Targeting: ๐ We've fixed an issue where the mousedown target was incorrectly used for click events. Now, the actual event target is used, aligning with standard click handling practices. This resolves the inconsistency noted in issue #3363.
That's a wrap for now! Keep coding, keep creating, and stay awesome! ๐ปโจ
Included Commits
The commit titled "validate slot options" introduces a new feature that enhances error handling in the Phoenix framework by adding compile-time warnings for invalid slot options. Previously, if a developer made a typo in defining slot optionsโsuch as using requird
instead of required
โthe mistake would go unnoticed, leading to potential issues in the application's behavior. With this update, if any options other than the accepted ones (:required
, :doc
, or :validate_attrs
) are passed to a slot, a compile-time error will be raised, providing immediate feedback to the developer.
In addition to the core functionality, the commit includes modifications to the relevant test suite to ensure the new validation behaves as expected. A new test has been added to verify that a CompileError
is raised when unsupported options are used in slot definitions. This enhancement not only improves code robustness by catching errors early in the development process but also promotes better coding practices by guiding developers toward the correct usage of slot options.
Files changed
- lib/phoenix_component/declarative.ex
- test/phoenix_component/declarative_assigns_test.exs
The commit titled "Fix docs callback and function links (#3359)" addresses several documentation issues within the Phoenix.LiveView
module. Specifically, it corrects references to the mount/3
function, changing them to the appropriate callback notation c:mount/3
. This adjustment enhances clarity and accuracy in the documentation, ensuring that users can correctly understand the functionality and usage of the on_mount
callback and associated lifecycle hooks.
In addition to the changes in the callback references, the commit also updates the documentation regarding the attach_hook
function, specifying that it should be used with four arguments instead of one. These modifications aim to provide clearer guidance to developers working with the Phoenix LiveView framework, ultimately improving the overall developer experience by ensuring that the documentation is precise and helpful.
Files changed
- lib/phoenix_live_view.ex
The commit addresses an issue in the Phoenix LiveView framework where the target for click events was incorrectly set to the mousedown target. This behavior was introduced in a previous commit and led to inconsistencies in how click events were processed, particularly when users clicked on a button and then moved the mouse away before releasing the click. The change ensures that the actual event target is used for determining the click event target, which aligns with standard click handling practices.
In the implementation, the code has been modified to utilize the e.target
directly for finding the closest binding related to the click event, rather than relying on the stale mousedown target. This update resolves the issue identified in issue #3363 and improves the reliability of click event handling in the framework. The changes involve a minor adjustment in the live_socket.js
file, with a few lines added and one line removed to reflect the new logic.
Files changed
- assets/js/phoenix_live_view/live_socket.js
This commit enhances the documentation for the clear_flash/1
and clear_flash/2
functions in the Phoenix.LiveView
module by including information about the lv:clear-flash
event. It explains that the flash can be cleared on the client side using this event, which is natively handled by LiveView.
Additionally, the commit provides examples demonstrating how to implement this functionality in a LiveView template using the phx-click
attribute. The documentation now includes practical examples that show how to trigger the flash clearing, making it easier for developers to understand and utilize this feature in their applications. Overall, the changes improve clarity and usability of the LiveView documentation.
Files changed
- lib/phoenix_live_view.ex
This commit focuses on updating the documentation for the Phoenix LiveView framework by removing all references to 'live_redirect' and replacing them with 'push_navigate.' The changes were made in various documentation files, including guides on the server's security model and related test files. The update aims to clarify the terminology used within the framework and ensure that developers are aligned with the latest naming conventions.
The modifications involved adjusting explanations and examples to reflect the new terminology while maintaining the technical accuracy of the content. By standardizing the references to 'push_navigate,' the documentation enhances understanding and usability for developers working with LiveView, ensuring they are informed about the current methods for navigation within the framework. The commit was co-authored by Chris McCord, indicating collaborative input in the documentation update process.
Files changed
- guides/server/security-model.md
- lib/phoenix_live_view/route.ex
- lib/phoenix_live_view/router.ex
- lib/phoenix_live_view/test/live_view_test.ex