DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
20.32k stars 779 forks source link

rAF + controlled inputs and fast input leads to cursor jump #114

Closed jkelleyrtp closed 1 year ago

jkelleyrtp commented 2 years ago

Reminiscent of:

https://github.com/Andarist/react-textarea-autosize/pull/100

If we update an input value twice in one frame, we get cursor jumping. This is because of rAF batching the two updates that happened in one frame. In reality, if we get a "synchronous" event, then it should be handled synchronously.

... the joys of following the footsteps of others.

To fix in web, we need to progress the VirtualDom from within the handler. Specifically for inputs/textareas.

To fix in desktop, we need to explicitly segment the two updates across frames, or nullify the first update.

For now, the problem is fixed enough in both platforms that it only appears during key spam.

jkelleyrtp commented 1 year ago

Raf is disabled. When it gets re-enabled, it'll not be used in synchronous events.