React: Wrong event.target.value

Created on 31 May 2018  路  4Comments  路  Source: facebook/react

Do you want to request a feature or report a bug?
bug
What is the current behavior?
Given: input field type='email'
When: type valid email address , after type 褋yrillic letter ([email protected] and type '写' (for test you can copy - paste it) )
Then: as a result , we have '[email protected]' and cursor in the start of input field
What is the expected behavior?
[email protected] in input field , which i can change
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
react version:16.3.1, browser: chrome 66
simple example https://codesandbox.io/s/3rrzz3qk6

Most helpful comment

I have tested it with the native input element. The example page: https://codepen.io/Alex1990/pen/BVoKVz?editors=1010.

In Chrome 66, the letter '写' will be encoded. But, in Firefox 60 and Safari 11, the letter will NOT be encoded.

If I convert the event.target.value to its unicode format manually with punycode.toUnicode() method, then all things will be as expected. See this example: https://codesandbox.io/s/mjop6yp37y

Also, you can use type="text" input and add the email validation by yourself.

Personally, I think this is a Chrome bug, or feature 馃槃.

All 4 comments

same issue
"react": "15.6.2"

It's Punycode parsing of 褋yrillic letter in email
for example, if try to copypast from browser url 泻芯褕泻邪.褉褎 it become xn--80atap4c.xn--p1ai
so i think value mutable is not a bug
BUT at some moment input set cursor to the start, and sometimes input mutable value sometimes not.

I have tested it with the native input element. The example page: https://codepen.io/Alex1990/pen/BVoKVz?editors=1010.

In Chrome 66, the letter '写' will be encoded. But, in Firefox 60 and Safari 11, the letter will NOT be encoded.

If I convert the event.target.value to its unicode format manually with punycode.toUnicode() method, then all things will be as expected. See this example: https://codesandbox.io/s/mjop6yp37y

Also, you can use type="text" input and add the email validation by yourself.

Personally, I think this is a Chrome bug, or feature 馃槃.

Thanks for additional research! I think it's resolved.

Was this page helpful?
0 / 5 - 0 ratings