You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
LiveSelect and LiveView versions
have you tried LiveSelect's and LiveView's latest versions? Please try them and see if the bug still occur
which LiveSelect version are you on? 1.5.2
which LiveView version are you on? 1.0.1
I'm happy to create a PR for this.
Describe the bug
The selection_recovery event gets submitted to a parent LiveView instead of the LiveSelect LiveComponent for live selects wrapped in LiveView's inputs_for component.
Expected behavior
The LiveSelect hook's reconnected callback pushes the selection_recover event to the live select LiveComponent.
Actual behavior
The LiveSelect hook's reconnected callback pushes the selection_recovery event to the parent live view.
Screenshots
If applicable (in most cases it is), do add a screenshot (or even better, a GIF or a video) that describes the problem.
Additional context
When the reconnected callback for the LiveSelect hook gets called, somehow the element that is being referred to in the pushEventTo call lacks DOM information on where the live component is. This can be traced to the owner call in the Phoenix JS code for live_socket which makes a call to el.closest(...). el.closest(...) returns null.
I believe a simple but effective fix would be to call pushEventTo(this.el.id, ...) instead of pushEventTo(this.el, ...). I think I tested this and it worked, but I can make sure that is the case.
The text was updated successfully, but these errors were encountered:
Can do! I'm looking into more about what the exact scenario is that causes this. I tried reproducing this in a new project with no success with an unchanging number of inputs. That leads me to think that perhaps it is a bit more nuanced than just live_select being wrapped in inputs_for. Perhaps the issue is an inputs_for that renders a dynamic number of inputs. Regardless, I think the solution is still the same.
We encountered the same issue, causing a crash loop on the LiveView process. I've tested replacing pushEventTo(this.el, ...)
with pushEventTo(this.el, ...) seems to fix it in our scenario too.
LiveSelect and LiveView versions
have you tried LiveSelect's and LiveView's latest versions? Please try them and see if the bug still occur
which LiveSelect version are you on?
1.5.2
which LiveView version are you on?
1.0.1
I'm happy to create a PR for this.
Describe the bug
The
selection_recovery
event gets submitted to a parent LiveView instead of the LiveSelect LiveComponent for live selects wrapped in LiveView'sinputs_for
component.Expected behavior
The
LiveSelect
hook'sreconnected
callback pushes theselection_recover
event to the live select LiveComponent.Actual behavior
The
LiveSelect
hook'sreconnected
callback pushes theselection_recovery
event to the parent live view.Screenshots
If applicable (in most cases it is), do add a screenshot (or even better, a GIF or a video) that describes the problem.
Browsers
Firefox
Issue Repo
The following repo demonstrates the issue.
https://github.com/atcherry/live_select_example
Additional context
When the
reconnected
callback for the LiveSelect hook gets called, somehow the element that is being referred to in thepushEventTo
call lacks DOM information on where the live component is. This can be traced to theowner
call in the Phoenix JS code forlive_socket
which makes a call toel.closest(...)
.el.closest(...)
returns null.I believe a simple but effective fix would be to call
pushEventTo(this.el.id, ...)
instead ofpushEventTo(this.el, ...)
. I think I tested this and it worked, but I can make sure that is the case.The text was updated successfully, but these errors were encountered: