-
Notifications
You must be signed in to change notification settings - Fork 34
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
How can I handle input changes myself #54
Comments
I think a workaround could be to support a That way I can just wrap my live selects in a nested form tag that owns them. |
I don't think it does because for validation and saving I still need the parent LV to handle the |
It should work. You have to add the |
I haven't been able yet to fix this. The best solution has been to use Still, I think that it might make sense to use a JS hook on my LiveComponent but I'm not sure if there is a way to stop form change events to propagate from the form inputs. |
Really hard to help you without seeing any code. Maybe you can share something? |
I have invited you to a poc repo which has the same setup and the same issue |
Thanks. I've taken a look. First of all, for your information, nested forms are not valid HTML. They're simply not allowed. Now, I don't know exactly what your hierarchical live select is supposed to be doing, maybe you can explain the idea behind it so I can suggest some design options? My guess is that your component is supposed to contain one or multiple live select elements and "intercept" change events from the live select inputs, so that they're handled in the component and not in the parent form's change event handlers. Is this correct? In this case, in LV, you can achieve this by using custom However, live select currently doesn't support this. I could add it though. Let me know. |
Yes, that is what I think I need, to intercept the event when an option is chosen without it bubbling up to the form. Thanks and sorry for the poor explanation. |
Ok, then I can add support for custom You are of course welcome to contribute a PR if you want to! |
I can try, apart from supporting the assigns I guess this is mostly js stuff? |
I believe there's no need for changes in the js hook. It should be enough to replicate the assigns in the hidden input elements that are used to contain the value of the selection. |
Hey @maxmarcon I have this working locally. We need two new assigns:
This is how I have called them, let me know if you'd rather use other names and if you agree with the approach. BTW, I saw that you are using hidden inputs because there were issues with select fields but I think that's no longer the case. |
Hey @Papipo and sorry for the late reply. Why do we need a new For Please share your code or create a PR, so we can have a more meaningful conversation about this :) thanks |
Hi!
First of all, thanks a lot for your work, it's great!
I wanted to create a dynamic hierarchical LiveComponent wrapping LiveSelect. The problem I have is that when an option is selected, it's the Root LiveView (through the form's phx-change) who gets the even.
I tried wrapping the Heex in another form tag but that didn't work. I don't know if there is any other way of having more control over who gets the change event.
There might be an obvious way but I am new to LiveView, sorry.
Thanks in advance,
Rodrigo.
The text was updated successfully, but these errors were encountered: