You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After refactoring parts of my application from using Elmish directly to using React components that use React.useElmish, I noticed various form inputs were misbehaving. Whenever you try to edit a form input by placing the cursor somewhere in the middle of a previously entered piece of text and start typing, the cursor jumps to the end of the field and you end up typing most of your characters in the wrong place.
The init, update and render functions are identical to the original code. Interestingly whenever I use prop.valueOrDefault instead of prop.value for keeping the input value in sync with the state, the jumping behaviour does not occur. Is this to be expected or perhaps a bug?
Reproduction steps
Given the following:
typeState={ Name:string }typeMsg= ChangeName ofstringletinit()={ Name =""}, Cmd.none
letupdate(msg:Msg)(state:State)=match msg with| ChangeName name ->{ state with Name = name }, Cmd.none
letrender(state:State)(dispatch:Msg ->unit)=
Html.div [
Html.input [ prop.className "input"
prop.value state.Name
prop.onChange (ChangeName >> dispatch)
prop.type'.text ]
Html.text state.Name
]
Issue
After refactoring parts of my application from using Elmish directly to using React components that use
React.useElmish
, I noticed various form inputs were misbehaving. Whenever you try to edit a form input by placing the cursor somewhere in the middle of a previously entered piece of text and start typing, the cursor jumps to the end of the field and you end up typing most of your characters in the wrong place.The
init
,update
andrender
functions are identical to the original code. Interestingly whenever I useprop.valueOrDefault
instead ofprop.value
for keeping the input value in sync with the state, the jumping behaviour does not occur. Is this to be expected or perhaps a bug?Reproduction steps
Given the following:
These functions work fine, if used like this:
However it breaks if I wrap them in a
ReactComponent
withuseElmish
:The text was updated successfully, but these errors were encountered: