jquery.alphanum icon indicating copy to clipboard operation
jquery.alphanum copied to clipboard

selectionStart incompatible on latest Chrome

Open tommeier opened this issue 12 years ago • 13 comments

Hi,

Chrome version: Version 33.0.1750.29 beta (and dev)

We're noticing errors when attaching to number fields:

InvalidStateError: Failed to read the 'selectionStart' property from 'HTMLInputElement': The input element's type ('number') does not support selection.

Have you noticed this? Any known workaround?

tommeier avatar Jan 23 '14 23:01 tommeier

Hi Tom I haven't seen this issue before. Any chance of a code example or a jsfiddle? Thanks Kevin

KevinSheedy avatar Jan 24 '14 16:01 KevinSheedy

Yep, I’m seeing this as well — will prepare a fiddle and try and replicate it for you.

plasticine avatar Jan 29 '14 05:01 plasticine

Hey, managed to knock up a fiddle that replicates the issue exactly for me in at least the following chrome versions;

  • Version 33.0.1750.46 beta
  • Version 34.0.1809.0 dev
  • Version 34.0.1811.0 canary

http://jsfiddle.net/plasticine/3XBwc/4/

screen shot 2014-01-30 at 10 49 32 am

plasticine avatar Jan 29 '14 23:01 plasticine

Thanks guys. As this is only happening in beta versions of Chrome, for now I'm going to assume this is actually a chrome bug. If you see it happening in any full release version of Chrome, please let me know and I'll definitely take another look. It's working fine in Chrome Version 32.0.1700.107 m

KevinSheedy avatar Feb 05 '14 17:02 KevinSheedy

FWIW, I’ve had reports of this error from end-users who are also seeing this error on Chrome stable on mobile devices.

plasticine avatar Feb 06 '14 23:02 plasticine

Looks like Chrome has disabled the select api for inputs of type number and email. Apparently this is in line with the current whatwg html spec. This has affected several libraries as well as jquery.alphanum.

I've sent the following email to the whatwg mailing list to try get clarification and to request that the select api be re-instated for input types email and password in the official html spec.

Hi

The Chrome browser recently disabled the select api for inputs of type number and email:
https://codereview.chromium.org/100433008/#ps60001

The select api is a collection of attributes and functions that allow us to get and set which portion of text a user has highlighted in an <input>

The attributes and functions in question are:
select()
selectionStart
selectionEnd
selectionDirection
setRangeText()
setSelectionRange()

This change caused bugs in several libraries:

http://stackoverflow.com/questions/21177489/selectionstart-selectionend-on-input-type-number-no-longer-allowed-in-chrome#

https://github.com/KevinSheedy/jquery.alphanum/issues/19

The spec says that these properties should be available for inputs of types text, search, url, telephone and password but not for inputs of type number or email.

I'd like to request that this collection also be made available to inputs of type number and email.

Does anyone have any insight as to why these types were excluded?

Many Thanks,
Kevin

KevinSheedy avatar Feb 22 '14 17:02 KevinSheedy

Awesome—thanks!

plasticine avatar Feb 23 '14 23:02 plasticine

FYI: Chrome stable on desktop is now exhibiting this behaviour.

tarragon avatar Feb 25 '14 01:02 tarragon

There's an active discussion currently happening on www.w3.org about possibly re-instating the selection API into the spec. This would fix the problem.

It would be great if you could logon and add your support.

KevinSheedy avatar Mar 05 '14 14:03 KevinSheedy

I've also logged it as a bug in chromium so it would be great if you could also add your support there.

KevinSheedy avatar Mar 05 '14 15:03 KevinSheedy

Awesome — will do. Thanks.

On 6 Mar 2014, at 2:25 am, KevinSheedy [email protected] wrote:

I've also logged it as a bug in chromium so it would be great if you could also add your support there.

— Reply to this email directly or view it on GitHub.

plasticine avatar Mar 05 '14 22:03 plasticine

This issue seems to have also started occurring in the newly released Firefox 29. :(

plasticine avatar Apr 30 '14 05:04 plasticine

A little update on this issue. This also happens with type email. if you take @plasticine example and replace it with email. It will display the exact same error. Funny enough the input type tel works fine with the .numeric on top of it.

Could anyone be kind enough to share a workaround for this error?

rjso avatar Oct 30 '14 16:10 rjso