This repo demonstrates an issue with live_select's selection_recover event.
All the necessary code is provided under ./lib/phx_playground_web/live/home.
The example is contrived, but is meant to replicate a similar setup in a repository
with this issue.
Setup the repo with mix setup
- Run the server with
mix phx.server - Select a dealer:
- Select a car and do not submit the form:
- Abort phx.server:
- Run
mix phx.serverto see the console spam that the parent LiveView has no function that handles eventselection_recovery
- Modify the
reconnected()callback in./deps/live_select/priv/static/live_select.min.jsby changingthis.pushEventTo(...):
// Before
reconnected() { this.selection && this.selection.length > 0 && this.pushEventTo(this.el, "selection_recovery", this.selection) }
// After change --↴
reconnected() { this.selection && this.selection.length > 0 && this.pushEventTo(this.el.id, "selection_recovery", this.selection) }before
after: call
this.el.idinstead ofthis.el
- Run
mix deps.compile - Perform the same steps to reproduce the issue.
- submit the form to see that the selection was conserved.




