-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
[LiveComponent] Form input in focus does not reset after submit by hitting enter #2438
Comments
resetForm reinitialize the form in the state it was when you created it normally... Can you explain precisely the suite of steps here (when it's created first, what actions are done, what is the result you get..) ? |
Hi Simon, thank you very much for your reply! The above code is the minimal setup for when it does not work as expected. The form is created by the live component on first render. The component gets imported via The interessting thing: When I blur the element before the submitting with the enter key, it works almost all the time as expected: the form gets emtpied. What I do now to make it more reliable: I did add another div as parent of the form with a random id. After each submit, I reset the form and regenerate this id (which is also a live prop). By this, it works as expected. Please let me know if you need more feedback! |
I'm not entirely sure, but the norender|* might be one reason, and the absence of initialFormData could be another. At this point, it's hard to say for certain 🤷 That said, providing a reproducer is more important than it might seem. Without it, I’d need to make several assumptions to match your scenario:
Quickly, this can turn into 10 minutes just trying to set up something that might resemble your case. The chances of getting help or clear answers are much higher if you provide a repository that others can directly install and test. I know it may not seem like a big deal, but those extra 10 minutes make a real difference. They allow contributors to focus their (often limited) free time on fixing bugs or adding new features instead of reconstructing your issue. Nothing personal or against you, just needed to clarify :) Let me know if none of these suggestions work for you! |
Thank you very much for the explanation. I really understand the issue with helping me and I will of course do anything which helps to resolve the issue (maybe also on my side!)
Here is the repo you asked for with the steps to reproduce my issue. https://github.com/michilehr/symfony-ux-demo Again, thanks a lot for taking the time @smnandre ! |
Thank you very much, that helps digging directly to the code / install. So indeed there is something here. The problem is .... it is "expected". Well.. let me explain. There is a special treatment for the active element of the page during the morph (the process replacing every element from the live component HTML in the page with its new value from the server). In your specific case, i agree there is something amiss, but that could be handle with stimulus easily i suppose? But this has been done for the scenarios where there is some time during morph, or to not lose the current content / input position when user is typing). That is also why we cannot do something on the back-end there.. So i don't know what would be the best way to improve this. Custom JS ? Some specific case to lose/regain focus ? |
Given I have a form with one field which should reset after submit, the field is not updated (emptied in my case) after hitting the enter button. By clicking the submit button, it works.
Any chance to solve this without writing JavaScript?
Thanks for any help!
The text was updated successfully, but these errors were encountered: