Skip to content

atcherry/live_select_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

live_select_example

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

Steps to reproduce the issue

  • Run the server with mix phx.server
  • Select a dealer:

dealer

  • Select a car and do not submit the form:

car

  • Abort phx.server:

abort

  • Run mix phx.server to see the console spam that the parent LiveView has no function that handles event selection_recovery

Steps to reproduce the fix

  • Modify the reconnected() callback in ./deps/live_select/priv/static/live_select.min.js by changing this.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

before

after: call this.el.id instead of this.el

after

  • Run mix deps.compile
  • Perform the same steps to reproduce the issue.
  • submit the form to see that the selection was conserved.

About

This repo demonstrates an issue with live_select's selection_recover event

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published