-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrading from v1.2.2 to v1.3.1 resets the input value #55
Comments
Hi Damir. Can you please share a minimal example (ideally with a repo) that reproduces the issue? Thanks |
I am facing the exact same issue, I have two components on the page and the component is reset suddenly after a few ms. Debugging it right now. Let's see if I can help. |
@shamanime thanks, that would be really helpful. If you could create a minimal repo that reproduces the issue, that should be enough for me to dig into it and fix it. |
I've updated this repo to simulate the issue: https://github.com/shamanime/async_stream_test Run it, add a user, go to the show page, click edit, update cars/fruits and click save. This action won't redirect/patch, instead it will just reload the form and then the live_select options disappear. I've sent you a DM on Elixir's Slack. Ping me there if you need more details or want to pair on it. |
thanks a ton @shamanime ! I can replicate the issue using your repo. I will dig into it soon. |
Thanks again for putting together the repo. The problem here is that live select doesn't know how to map the shape of the You're working around this problem in your Live select looks at the value of the form's field, and assumes it's in the expected format for an option. I realize now that this is a bit naive and only works for simple fields like integers and strings, but not for fields whose values can be structs, like in your case. Perhaps a possible solution could be to provide a For example, in your case, something like this: <.live_select value_mapper={fn %Item{name: name, id: id} -> %{label: name, value: id} end} /> What do you think? |
it seems to be more complex than I initially thought. The element of an embedding could also be a changeset . I need to think about it with more calm. Any idea is welcome! |
FYI: Ok I think I wrapped my head around this. Will come back with a plan when I find some time. Stay tuned! |
@shamanime I made LiveSelect changeset aware, so it can now handle embedded schemas easily. I also added a These changes aren't in main yet, but in a separate value_mapper branch. I created a PR for your application that explains and showcases the changes: Everything should be much simpler now and work without problems. There are still some open questions though, I'd be very thankful for your feedback! 🙏 |
Closed with 1.4.0 |
Hi Max,
I added 200 ms delay in
handle_params
so it is visible in the recording below.The log is the same in both versions:
It is triggered when the updated stream is added to the socket:
Looks like the whole component is re-rendered:
live_select.mov
The text was updated successfully, but these errors were encountered: