NativeScript icon indicating copy to clipboard operation
NativeScript copied to clipboard

TextField text cursor going to the first position after value update

Open tsonevn opened this issue 7 years ago • 6 comments

From @yassern on May 25, 2018 19:49

This bug is android only, I have a Slider and a TextField that have the same ngModel attribute reference and when the value of that attribute is updated, the cursor goes to the first position of the input, no matters if the user use the textfield or the slider.

Sample project: https://play.nativescript.org/?template=play-ng&id=O0oLGQ&v=1

Copied from original issue: NativeScript/nativescript-angular#1348


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

tsonevn avatar May 28 '18 08:05 tsonevn

Hi @yassern, Thank you for contacting us. I tested this case and found that it is reproducible also in a non-Angular project. For further info, please keep track on the issue.

tsonevn avatar May 28 '18 08:05 tsonevn

Is there any workaround for this bug?

neil-119 avatar Aug 04 '18 07:08 neil-119

Seems this is open from last 2 years. Have anyone found any solution to this ?

faisalansari20 avatar Nov 16 '20 06:11 faisalansari20

This is the workaround which i found.

if (isAndroid) { setTimeout(() => { textField.android.setSelection(textField.text.length) }, 0) }

faisalansari20 avatar Nov 16 '20 06:11 faisalansari20

@faisalansari20 Thanks man, you avoided an afternoon headache. Didn't worked out without that timeout, but is still kinda annoying to see the cursor jumping back and forth. Hope they fix these little things some day

MPerezMateo avatar Dec 12 '20 17:12 MPerezMateo

having this problem recently also

zeejay09 avatar Apr 05 '22 08:04 zeejay09