-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Input type email bug #14168
Comments
It happens because the browser trim the spaces from the end of the value. Modify your code as follows to see what happens: inputOnChange = ({ target }) => {
console.log('\'' + target.value + '\'');
this.setState({ [target.name]: target.value });
} Looks already discussed here #6368 |
This means we have to choose between using an uncontrolled input with My "solution" is to swallow the event if it's a space: // Controlled email input
<input
type="email"
value={this.state.value}
onChange={this.onChange}
onKeyPress={this.onKeyPress} />
onKeyPress = syntheticEvent => {
if (syntheticEvent.charCode === 32) {
syntheticEvent.preventDefault();
}
}
onChange = evt => {
this.setState({ value: evt.target.value });
} This won't work if a user pastes an email with a space in it, but it's the least terrible bandaid I could come up with 🙈 |
A similar issue was reported on Material-UI side. The regression seems to have come between React v16.2.0 and v16.3.0: https://codesandbox.io/s/xrv5w1j90w. |
I've narrowed down to where this problem was introduced - it first appears because of the changes in As I can see in |
…table working with type 'email'. Bugs in react: facebook/react#14168 facebook/react#6368
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution. |
I'm still getting this bug on React 16.12.0 |
same here, any fixes? |
I made a fix in chrome which should fix this problem which should be released in chrome 85, try it out on canary: https://www.google.com/chrome/canary/ |
Hi, I'm still seeing this issue on React v16.13.1. Seeing it on Chrome browser. Anyone here observed the same on the latest React version 16.13.1? Someone here has the fix for this issue? Thanks. |
@JCC13 Did you try it in chrome canary? The fix is not in stable chrome yet. |
@gaearon I believe this issue is fixed.
|
@josepharhar I can confirm that this bug is fixed in Chrome 86 with React 16.13.1. |
https://codepen.io/anon/pen/GwZeNO
Open this codepen and paste this "[email protected] 1"
Then press backspace, notice that the focus changes to the beginning of the input.
The text was updated successfully, but these errors were encountered: