# TextInput Issue with Cursor when adding text

**URL:** <https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926>\
**Category:** Bug Reports\
**Created:** [November 14, 2019, 9:56am UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926 "2019-11-14T09:56:08Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_13](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stefan\_13](https://forums.fusetools.com/u/Stefan_13)\
**Post date:** [November 14, 2019, 9:56am UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/1 "2019-11-14T09:56:08Z")

</div>

I have got an Issue with the TextIput.  
I want to check the input text and and a “-” when the String’s length == 3.  
But when I add the String, the cursor is on the 3. position (“aaa|-”) and not on the 4. (“aaa-|”)

I do it like this:

> var textInput = Observable(“”);  
> textInput.onValueChanged(module, function(character) {  
> if(textInput.value.length==3){  
> textInput.value= textInput.value + “-”;  
> }  
> });

Hope you know what I mean 🙂  
Thanks!

---

<div class="post-metadata">

**Author:** ![Stefan\_13](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stefan\_13](https://forums.fusetools.com/u/Stefan_13)\
**Post date:** [November 17, 2019, 2:59am UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/2 "2019-11-17T02:59:20Z")

</div>

No one, who has the same problem? 🙊✌🏼

---

<div class="post-metadata">

**Author:** ![Matti\_Tihverainen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/matti_tihverainen/32/684_2.png) [@Matti\_Tihverainen](https://forums.fusetools.com/u/Matti_Tihverainen)\
**Post date:** [November 17, 2019, 5:06pm UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/3 "2019-11-17T17:06:30Z")

</div>

Hello! Have you tried blurring the input, adding the character and then refocusing on it?

---

<div class="post-metadata">

**Author:** ![Stefan\_13](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stefan\_13](https://forums.fusetools.com/u/Stefan_13)\
**Post date:** [November 17, 2019, 5:21pm UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/4 "2019-11-17T17:21:25Z")

</div>

No, but could you help me how to archieve this? 🙂

---

<div class="post-metadata">

**Author:** ![Stefan\_13](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stefan\_13](https://forums.fusetools.com/u/Stefan_13)\
**Post date:** [November 18, 2019, 9:54am UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/5 "2019-11-18T09:54:31Z")

</div>

Is there a Javascript function to refocus? ✌🏼  
Do you have the same issue? 🙊

---

<div class="post-metadata">

**Author:** ![Matti\_Tihverainen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/matti_tihverainen/32/684_2.png) [@Matti\_Tihverainen](https://forums.fusetools.com/u/Matti_Tihverainen)\
**Post date:** [November 18, 2019, 7:53pm UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/6 "2019-11-18T19:53:58Z")

</div>

Sorry, I’ve never had to tackle this issue. I hope someone else could comment on how to focus from JS. I’ve always done it straight from the UX.

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [November 18, 2019, 9:43pm UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/7 "2019-11-18T21:43:56Z")

</div>

Haven’t had the need to move the caret yet but what is the UX way? …cos can just use an Observable and a `<WhileTrue>` trigger to trigger off UX.

---

<div class="post-metadata">

**Author:** ![Stefan\_13](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stefan\_13](https://forums.fusetools.com/u/Stefan_13)\
**Post date:** [November 18, 2019, 10:02pm UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/8 "2019-11-18T22:02:03Z")

</div>

Actualy I dont want to move the caret but I think I have to, because it seems to be a bug…Dont you have the same issue?

I want to achieve a TextInput with a regex in form of : “AAA-AAA-AAA”.  
And I tried to add automatically a “-” when the string is length==3. But then the caret moves infromnt of the “-” and not at the end 😕

Maybe I need to do something else? xD

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [November 19, 2019, 8:00am UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/9 "2019-11-19T08:00:53Z")

</div>

Maybe you can try separate input fields for the different parts and when they complete a field, you move the focus to the next field?

---

<div class="post-metadata">

**Author:** ![Stefan\_13](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@Stefan\_13](https://forums.fusetools.com/u/Stefan_13)\
**Post date:** [November 21, 2019, 5:01pm UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/10 "2019-11-21T17:01:11Z")

</div>

Sorry for the late reply! And thanks for the workaround! Thats the way I did it now 🙂

But I really want only one Texfield 😕 But does no one else got this Problem? Is there no one who uses paettern/regex ?! x)

✌✌

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [November 22, 2019, 11:08am UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/11 "2019-11-22T11:08:04Z")

</div>

I don’t think the issue is with regex; we need to add more caret functionality to TextInput, suggest it in the Wishlist on slack 😉

---

<div class="post-metadata">

**Author:** ![Hassan\_M](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/hassan_m/32/957_2.png) [@Hassan\_M](https://forums.fusetools.com/u/Hassan_M)\
**Post date:** [November 22, 2019, 12:02pm UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/12 "2019-11-22T12:02:15Z")

</div>

The caret doesn’t move if you change the content of TextInput not by the system keyboard, that is expected behavior, what we needed just @aeq said are features to set caret position programmatically and other functionality such as text selection, copy and paste.

I am in implementing the Scriptclass method for TextInput for setting a caret position in the javascript. I hope it will be finished this weekend.

---

<div class="post-metadata">

**Author:** ![aeq](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/aeq/32/129_2.png) [@aeq](https://forums.fusetools.com/u/aeq)\
**Post date:** [November 22, 2019, 7:31pm UTC](https://forums.fusetools.com/t/textinput-issue-with-cursor-when-adding-text/7926/13 "2019-11-22T19:31:32Z")

</div>

Shweet @Hassan_M 💪, yeah, we need all that goodness you just mentioned 😆
