Keep cursor position and focus on input field while typing after a backend request

If you wrap your Elm Html in Html.keyed, it will avoid overwriting the DOM every time your view function is called.

To absoluately ensure this works, you may need to add Html.keyed all the way up to the root of your Html. Often just wrapping the input and everything at its level is fine.

A fairly recent discussion on the subject:

You can try it out by adding Html.keyed into this Ellie:

https://ellie-app.com/g85Cv3rQY2ya1