field-kit icon indicating copy to clipboard operation
field-kit copied to clipboard

PhoneFormatter steals focus when the page is loaded

Open gqqnbig opened this issue 8 years ago • 8 comments

Steps to reproduce:

  1. Go to the demo page
  2. Do not click any mouse button. Wait until the page is fully loaded, then hit keyboard key 1.

What is expected:

3 As the focus is not on any input control, the page should not change.

What happened actually:

3 The page suddenly scrolls from top to PhoneFormatter field, and "1" is input to the field.

It happens in Chrome 49.0.2623.87 m and IE 11, but not in FireFox 42.0.

gqqnbig avatar Apr 11 '16 22:04 gqqnbig

ok, I found it's related to this.setSelectedRange() in TextField method (https://github.com/square/field-kit/blob/master/src/text_field.js#L93). If I remove setSelectedRange, the issue doesn't happen.

gqqnbig avatar Apr 11 '16 22:04 gqqnbig

Are you saying that this happens on any page that the phone formatter is on? Or just the demo page? It also doesn't happen in Safari.

eventualbuddha avatar Apr 11 '16 23:04 eventualbuddha

@eventualbuddha sorry, I just updated my comments. It happens in Chrome 49.0.2623.87 m and IE 11, but not in FireFox 42.0. It's related to this.setSelectedRange() in TextField method.

gqqnbig avatar Apr 11 '16 23:04 gqqnbig

This seems to happen on Safari as well.

jjwon0 avatar Apr 12 '16 05:04 jjwon0

Note, if you are unable to reproduce the issue, disable all browser extensions as they may set focus and hide the problem.

gqqnbig avatar Apr 12 '16 11:04 gqqnbig

+1 this issue is exist

dev0x10 avatar Oct 17 '16 09:10 dev0x10

I can confirm this happens on Safari on iOS. I cannot reproduce in Chrome on OS X however. As @gqqnbig said, if I remove the call to setSelectedRange it fixes this issue.

hoverlover avatar Mar 01 '17 03:03 hoverlover

Also, for a little more context, it seems to auto-scroll to the field that was last initialized with a FieldKit.TextField.

hoverlover avatar Mar 01 '17 03:03 hoverlover