symfony / ux

Symfony UX initiative: a JavaScript ecosystem for Symfony
https://ux.symfony.com/
MIT License
826 stars 297 forks source link

[Live component] Data model binding "onblur" not available #2194

Open richardhj opened 1 week ago

richardhj commented 1 week ago

Hi there!

I posted on this issue before in Slack 😄

In fact, I have a input type="date" that (as we know) has strange "onchange" behaviors.

My idea was to submit the field onblur, but this is not available. Is there a reason for doing so?

https://github.com/symfony/ux/blob/9209d8640a3004540f9abf3d34a9d5dc888371eb/src/LiveComponent/assets/src/Directive/get_model_binding.ts#L24-L27

2024-07-13 00 27 38

smnandre commented 1 week ago

The problem is that "blur" does not imply any change, and would probably be triggered too late in many cases..

Also, this is a browser "bug" in the end... and i'm not sure we want to try going against it ... :/

But, by setting a small debounce, the experience looks to me already much better!

https://github.com/user-attachments/assets/59f811fc-4004-4c56-9248-34bf78e1a3fd

What do you think ?

If this does not match what you want, you also can set a norender on change, and trigger the event manually from some custom JS script / Stimulus controller (see: https://symfony.com/bundles/ux-live-component/current/index.html#model-updates-don-t-work-when-external-javascript-changes-a-field)