Open flyingmachine opened 1 week ago
I originally implemented this solution for input fields: https://github.com/reagent-project/reagent/blob/886d2035518a77cb7f1ecf713256fd0fee89bd72/src/reagent/impl/input.cljs#L34-L74
But it relies on selection API being present on the input: https://github.com/reagent-project/reagent/blob/886d2035518a77cb7f1ecf713256fd0fee89bd72/src/reagent/impl/input.cljs#L9-L10
I think email
can easily be added to that list because these days it supports the necessary API. (Maybe it always did).
But it doesn't appear as if number
can be added - so that would have to be solved another way, probably with much more effort.
Fixing for email type seems simple enough.
Related: https://github.com/reagent-project/reagent/issues/504 Removing the rAF scheduling would remove the need for input workaround, but it would also be a big breaking change in Reagent so not sure if it going to happen ever. You could use UIx/Helix instead.
Inputs of type
:email
and:number
exhibit the controlled-input cursor bug: as you type, the cursor will always reappear at the end end of the input. Inputs of type:text
and:password
don't exhibit this behavior.Little repo to repro: https://github.com/flyingmachine/reagent-react-18-controlled-input