-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Bug: Input don't send "select" events when type is "email" #31156
Comments
I think it's not a React bug, but rather a limitation of HTML and DOM behavior. The onSelect event is designed for text inputs, and the HTML specification does not define this event for email-type inputs. Therefore, React behaves according to this specification. If you are facing a specific case where you need to select text in an email input, the solution would be to use an input of type text with validation to ensure that the value is a valid email. This way, you can use onSelect and other events normally. |
Hum... It might be. That's totally stupid, though. Why would you not need to listen to the selection position on email inputs specifically? Anyway, if that's the cause and React cannot handle this in another way, then we should probably update @types/react to not let you use onSelect on input if the type is "email", no? |
With native events this actually just works on Also, the select event is not limited to any particular https://html.spec.whatwg.org/multipage/indices.html#event-select So React actually behaves counter to specification if it only raises this on
|
I'll try to answer this bug, I don't know is this a bug or what, I understand this issue focus on how consistent reactjs to js API, but I'll try little hacky way to achieve this expectation of behaviour, I use |
React version: reproduced on 17 and 18
Steps To Reproduce
<input text="move the selection around" onSelect={console.log} type="email" />
Link to code example:
https://codesandbox.io/p/sandbox/recursing-kilby-z6h9dz?file=%2Fsrc%2FApp.js%3A15%2C1
The current behavior
Does not emit "select" events
The expected behavior
Should emit the "select" events
The text was updated successfully, but these errors were encountered: