# Cursor jumps to end of text in input fields

**URL:** <https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937>\
**Category:** Learn\
**Created:** [September 11, 2018, 5:29am UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937 "2018-09-11T05:29:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paulh/32/5022_2.png) [@paulh](https://discourse.elm-lang.org/u/paulh)\
**Post date:** [September 11, 2018, 5:29am UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937/1 "2018-09-11T05:29:28Z")

</div>

Ive upgraded to Elm 0.19 and have upgraded my Style Elements package to 5.0.1

Now, when I enter text at the beginning of a text field that has text in it, the cursor jumps to the end of the text after each key press, and stays there. A multiline textarea does not suffer from this, it only appears to be single line text fields.

Has anybody else seen this behaviour? If its just me then I guess it must be a bug in my code.

I do intend to swap out Style Elements for Elm UI but thats going to be a fair re-write so was hoping to fix this issue first.

---

<div class="post-metadata">

**Author:** ![jinjor](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jinjor/32/386_2.png) [@jinjor](https://discourse.elm-lang.org/u/jinjor)\
**Post date:** [September 11, 2018, 6:15am UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937/2 "2018-09-11T06:15:56Z")

</div>

This is a bug and already reported.

- [https://github.com/elm/html/issues/174](https://github.com/elm/html/issues/174)
- [https://github.com/elm/virtual-dom/issues/138](https://github.com/elm/virtual-dom/issues/138)

(This problem prevent us from migrating the production app to 0.19.)

---

<div class="post-metadata">

**Author:** ![paulh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paulh/32/5022_2.png) [@paulh](https://discourse.elm-lang.org/u/paulh)\
**Post date:** [September 11, 2018, 7:17am UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937/3 "2018-09-11T07:17:31Z")

</div>

OK thanks for the info.

---

<div class="post-metadata">

**Author:** ![popara](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/popara/32/719_2.png) [@popara](https://discourse.elm-lang.org/u/popara)\
**Post date:** [September 12, 2018, 6:31pm UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937/4 "2018-09-12T18:31:18Z")

</div>

I saw your issues on GitHub and I could reproduce Ellie examples from Safari, but having tested my partially moved application I could not reproduce the issue!

I will push it to public staging server, so you can take a look, but basically that issue doesn’t appear in my App.  
I didn’t want to make noise on GitHub, since I didn’t investigated WHY doesn’t happen, but I can assure you that I used vanilla Elm way of populating that text input field.

---

<div class="post-metadata">

**Author:** ![jinjor](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/jinjor/32/386_2.png) [@jinjor](https://discourse.elm-lang.org/u/jinjor)\
**Post date:** [September 13, 2018, 6:37am UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937/5 "2018-09-13T06:37:32Z")

</div>

This is fixed on the latest elm/virtual-dom@1.0.1! 🎉

@popara

> I can assure you that I used vanilla Elm way of populating that text input field.

I don’t know what is “vanilla Elm way”, but maybe you mean _not_ assigning `value` could solve this problem? So,

```auto
input [onInput Input] []

```

instead of

```auto
input [value model.value, onInput Input] []

```

The former also works well on simple cases where you don’t need to _reset the value programatically_.

---

<div class="post-metadata">

**Author:** ![paulh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/paulh/32/5022_2.png) [@paulh](https://discourse.elm-lang.org/u/paulh)\
**Post date:** [September 13, 2018, 6:43am UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937/6 "2018-09-13T06:43:59Z")

</div>

> [@jinjor](#):
>
> This is fixed on the latest elm/virtual-dom@1.0.1! 🎉

Updated virtual-dom this morning, all good now.

---

<div class="post-metadata">

**Author:** ![popara](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/popara/32/719_2.png) [@popara](https://discourse.elm-lang.org/u/popara)\
**Post date:** [September 13, 2018, 7:15am UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937/7 "2018-09-13T07:15:05Z")

</div>

Actually I thought the former, with input type specified, eg.

`input [type_ "text", value model.value, onInput Input] []`

Maybe having a type specified elevated the issue.

That is now beside the point, because now it will work everywhere ^^

Good luck migrating to 0.19!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [September 23, 2018, 7:15am UTC](https://discourse.elm-lang.org/t/cursor-jumps-to-end-of-text-in-input-fields/1937/8 "2018-09-23T07:15:07Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
