phoenix_live_view
Advanced tools
Changelog
0.14.0 (2020-07-07)
document.activeElement
creates a null referenceliveSocket.disconnect()
followed by liveSocket.connect()
error_tag
failing to be displayed for non-text based inputs such as selects and checkboxes as the phx-no-feedback
class was always appliedphx-error
class being applied on live_redirect
__MODULE__
phx-static
not being sent from the client for child viewsbeforeDestroy
is called on hooks in children of a removed elementmount
, handle_params
, and handle_event
push_event
for pushing events and data from the server to the clienthandleEvent
hook method for receiving events pushed from the serverpushEvent
from the server via {:reply, map, socket}
assigns.myself
a struct to catch mistakessend_update
, raise if module is unavailableChangelog
0.13.3 (2020-06-04)
live_redirect
ed route results in a redirect to a non-live route on the serverdom
option to LiveSocket
with onBeforeElUpdated
callback for external client library support of broad DOM operationsChangelog
0.13.2 (2020-05-27)
Changelog
0.13.1 (2020-05-26)
push_redirect
from a live_redirect
Changelog
0.12.1 (2020-04-19)
innerHTML
being discarded when a sibling DOM element appears above it, in cases where the component lacks a DOM IDphx-disable-with
and other pending attributes failing to be restored when an empty patch is returned by serverChangelog
0.12.0 (2020-04-16)
This version of LiveView comes with an overhaul of the testing module, more closely integrating your LiveView template with your LiveView events. For example, in previous versions, you could write this test:
render_click(live_view, "increment_by", %{by: 1})
However, there is no guarantee that there is any element on the page with a phx-click="increment"
attribute and phx-value-by
set to 1. With LiveView 0.12.0, you can now write:
live_view
|> element("#term .buttons a", "Increment")
|> render_click()
The new implementation will check there is a button at #term .buttons a
, with "Increment" as text, validate that it has a phx-click
attribute and automatically submit to it with all relevant phx-value
entries. This brings us closer to integration/acceptance test frameworks without any of the overhead and complexities of running a headless browser.
assert_patch/3
and assert_patched/2
for asserting on patchesfollow_redirect/3
to automatically follow redirects from render_*
eventsphx-trigger-action
form annotation to trigger an HTTP form submit on next DOM patchphx-target
@myself
targeting a sibling LiveView component with the same component IDphx:page-loading-stop
firing before the DOM patch has been performedphx-update="prepend"
failing to properly patch the DOM when the same ID is updated back to backphx-error-for
has been removed in favor of phx-feedback-for
. phx-feedback-for
will set a phx-no-feedback
class whenever feedback has to be hidden
Phoenix.LiveViewTest.children/1
has been renamed to Phoenix.LiveViewTest.live_children/1
Phoenix.LiveViewTest.find_child/2
has been renamed to Phoenix.LiveViewTest.find_live_child/2
Phoenix.LiveViewTest.assert_redirect/3
no longer matches on the flash, instead it returns the flash
Phoenix.LiveViewTest.assert_redirect/3
no longer matches on the patch redirects, use assert_patch/3
instead
Phoenix.LiveViewTest.assert_remove/3
has been removed. If the LiveView crashes, it will cause the test to crash too
Passing a path with DOM IDs to render_*
test functions is deprecated. Furthermore, they now require a phx-target="<%= @id %>"
on the given DOM ID:
<div id="component-id" phx-target="component-id">
...
</div>
html = render_submit([view, "#component-id"], event, value)
In any case, this API is deprecated and you should migrate to the new element based API.
Changelog
0.11.1 (2020-04-08)
unless
in LiveEEx enginerender_event
/render_click
and friends now expect a DOM ID selector to be given when working with components. For example, instead of render_click([live, "user-13"])
, you should write render_click([live, "#user-13"])
, mirroring the phx-target
API.@socket.assigns[...]
in a template will now raise the exception Phoenix.LiveView.Socket.AssignsNotInSocket
. The socket assigns are available directly inside the template as LiveEEx assigns
, such as @foo
and @bar
. Any assign access should be done using the assigns in the template where proper change tracking takes place.defaults
option on LiveSocket
constructor to configure default phx-debounce
and phx-throttle
values, allowing <input ... phx-debounce>
detail
key to click event metadata for detecting double/triple clicksChangelog
0.11.0 (2020-04-06)
Remove socket.assigns
during render to avoid change tracking bugs. If you were previously relying on passing @socket
to functions then referencing socket assigns, pass the explicit assign instead to your functions from the template.
Removed assets/css/live_view.css
. If you want to show a progress bar then in app.css
, replace
- @import "../../../../deps/phoenix_live_view/assets/css/live_view.css";
+ @import "../node_modules/nprogress/nprogress.css";
and add nprogress
to assets/package.json
. Full details in the Progress animation guide
phx:page-loading-stop
@foo.bar
only executes and diffs when bar changes@myself
assign, to allow components to target themselves instead of relying on a DOM ID, for example: phx-target="<%= @myself %>"
enableProfiling()
and disableProfiling()
to LiveSocket
for client performance profiling to aid the development processChangelog
0.10.0 (2020-03-18)
@live_view_module
to @live_module
@live_view_action
to @live_action
put_live_layout
is no longer supported. Instead, use put_root_layout
. Note, however, that the layout given to put_root_layout
must use @inner_content
instead of <%= render(@view_module, @view_template, assigns) %>
and that the root layout will also be used by regular views. Check the Live Layouts section of the docs.phx-update="ignore"
hook if data attributes have changed.html.leex
template of the same basename of the LiveView will be automatically used for render/1
live_title_tag/2
helper for automatic prefix/suffix on @page_title
updatesChangelog
0.9.0 (2020-03-08)
:use
on child LiveViewsfalse
in the router and on mountfetch_flash
before):flash
is given as an assignsocket.router
MFArgs
as the :session
option in the live
router macro