This is a migrated thread and some comments may be shown as answers.

Cursor is never at the beginning

3 Answers 707 Views
MaskedTextBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Iron
Iron
Veteran
Paul asked on 03 Aug 2020, 07:34 PM

When a user clicks on the masked text box and there is no current value then the cursor should be at the beginning (left).

This does not happen. But you've had forum posts in the past and you told the poster that it should do this. I even see two bugs written for it: here and here. They both seem to indicate this is the expected behavior.

This doesn't work even in the online demos. Using a standard desktop with Chrome or using a touch screen device (Surface) I get the same behavior. The cursor goes wherever I clicked.

How can I force the cursor to always go to the far left?

3 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 05 Aug 2020, 11:16 AM

Hello Paul,

I checked this scenario in our online demos, and it seems that it working as expected - https://demos.telerik.com/kendo-ui/maskedtextbox/events

In the provided links, I see that you shared both a Kendo for jQuery and Kendo for Angular links. Could you please confirm that you are using the Kendo UI for jQuery?

If this is the case, could you please elaborate on how to replicate the scenario? It would be very helpful if you can share a sample page that isolates the issue.

I look forward to hearing from you.

 

Regards,
Preslav
Progress Telerik

0
Paul
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 05 Aug 2020, 01:37 PM

Using Chrome 84 on a Windows 10 PC. Three scenarios:

1 - Turn ON autofill in Chrome. This is on by default for users. Move your cursor into the phone box on the page you linked to. Click anywhere. Cursor stays exactly there. It never moves to the beginning. I can replicate this 100% of the time.

 

2 - Below the box in step 1 the autofill popup occurs. Chrome does not abide by HTML for autocomplete="off". If you move the mouse over any autofill item your cached phone number will temporarily fill in from the browser. Even if you only moved over that saved phone number for an instant. The browser will then clear the box as your mouse leaves the autofill window. The cursor will always be left at the very end of the box.

2 - Turn OFF autofill. Now the cursor will move to the beginning 75% of the time. Still doesn't work the other 25%. Seems to be random.

I am only referring to blank boxes.

0
Preslav
Telerik team
answered on 07 Aug 2020, 01:56 PM

Hi Paul,

I tested the scenario, and I was not able to replicate the 25% chance of cursor not going to the beginning. However, I believe that this could be workarounded by manually changing the position of the cursor. For example, handle the focus event of the input. In the event handler, use the setSelectionRange JavaScript method to set the desired position. I would recommend using a TimeOut in order to make sure that the mask is already rendered. The code could look like:

          $("#maskedtextbox").on("focus", function(e){
            setTimeout(function(){
            	e.target.setSelectionRange(0, 0);
            }, 1)
          });

For a runnable example, check this Dojo - https://dojo.telerik.com/EyuRadUv

Further, about the autocomplete issue in Chrome. I searched the web, and it seems that Chrome is known for such problems. You could try workarounding this faulty behavior by following the suggestions from this forum - https://stackoverflow.com/questions/30053167/autocomplete-off-vs-false

I hope the above information helps.

 

Regards,
Preslav
Progress Telerik

Tags
MaskedTextBox
Asked by
Paul
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Preslav
Telerik team
Paul
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or