Skip to content

Commit e08bb6c

Browse files
committed
clarify navigation in chained JS commands
Closes #4411.
1 parent eba3493 commit e08bb6c

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

  • lib/phoenix_live_view

lib/phoenix_live_view/js.ex

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,17 @@ defmodule Phoenix.LiveView.JS do
206206
it is guaranteed that the event will be pushed first and the patch will only be handled after
207207
the first event was handled by the LiveView.
208208
209+
> #### A note on navigation {: .warning}
210+
>
211+
> When `JS.push` is followed by navigation that replaces the current LiveView,
212+
> such as `JS.navigate`, the navigation may terminate the LiveView while it is
213+
> still handling the pushed event. The commands are executed in order, but the
214+
> event handler is not guaranteed to complete. If the event must finish before
215+
> navigation, initiate the navigation from `handle_event/3` instead, for example
216+
> with `push_navigate/2`.
217+
>
218+
> This does not apply to `JS.patch`, which keeps the current LiveView process running.
219+
209220
'''
210221
alias Phoenix.LiveView.JS
211222

0 commit comments

Comments
 (0)