Description
Environment
- Elixir version (elixir -v): 1.18.1
- Phoenix version (mix deps): 1.7.18
- Phoenix LiveView version (mix deps): 1.0.1
Actual behavior
After moving to LiveView 1.0 I encountered the following problem. We integrate flatpickr for date inputs using clients hooks (e.g. phx-hook).
This library dynamically generates an alternative form input element that allows interaction and hides the original input element (using the type="hidden" attribute).
After changing to the new way to track used inputs I noticed that inputs with this hook are never marked as unused. This makes the input immediately seem used after a handle_event cycle. In cases where the input is validated as required for example, this makes the input show up with its error markup and validation error, even though an unrelated input has triggered the validation while the date input is untouched.
I guess there are more JS libraries that use a similar pattern (adding an alternative input field, hide the original, and keep them in sync). All libraries using a similar pattern should see this change in behaviour with LV 1.0.
I see that hidden fields don’t get a companion parameter with the unused prefix by design: see here. There is also some reasoning about not sending the unused-parameters for hidden fields in this PR: #3244.
For an example integration see this gist of @mcrumm (which would also break with LV 1.0):
https://gist.github.com/mcrumm/88313d9f210ea17a640e673ff0d0232b
Expected behavior
Consider also adding the unused companion param for hidden inputs to allow this type of JS integration without breaking tracking of unused inputs.