-
Notifications
You must be signed in to change notification settings - Fork 3.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
use real beforeinput
events in all browsers that fire them
#2060
Comments
For more information about what we currently do... it helps to first understand the background on how "input events" work in browsers (or at least the ones we're concerned with).
Firefox and Edge do not support either Input Events spec, unfortunately. Although Edge has committed previously to supporting it, and Firefox has an (old) open issue for supporting it. Chrome on the other hand, supports Level 1, but has previously publicly fought against Level 2 support, so it's unclear if they will ever support Level 2 in the future or not. And a final complicating factor... React doesn't actually support the |
Also, some information about how we currently handle spellcheck corrections, which would change with Input Events as well... When correcting a word with spellcheck, browsers that haven't yet implemented the Input Events Level 1 spec (eg. Firefox & Edge) don't actually fire any DOM event before the spellcheck correction edits the DOM. They only fire the Because of this, there's no way to prevent the correction from happening, so we have to run a "diff" on the DOM to figure out what changed. Currently, we use the
This works for the most part. (Note: since we have to map DOM nodes to In browsers that have implemented Input Events Level 1 however, they should fire a |
f812816 was a good step toward this. Unfortunately I am seeing some problems with composition input in Safari. The Before plugin "eats" the That led to a further problem with the I made it "mostly work" with a hack to check if the model text we compare the DOM text of |
Fixed by #3093. |
Do you want to request a feature or report a bug?
Improvement.
What's the current behavior?
Right now we're only using real
beforeinput
events on iOS. In both Chrome and Safari on the desktop we're still using React's fakeonBeforeInput
event, which is actually just a polyfill that fires withkeydown
andtextInput
events. It hasn't yet been hooked up to use the realbeforeinput
event if one exists. I've opened an issue a while back for this here: facebook/react#11211 (If anyone wants to take a stab at pull requesting that functionality, that would be amazingly helpful!)What's the expected behavior?
We should change the core logic to use real
beforeinput
events on all browsers that support them, since this is what browsers are converging to. Right now they are supported in:And not supported in:
For now, I think it would make sense to aim for Level 1 support (which are non-preventable) and later we can refactor to add Level 2 support once browsers other than Safari start supporting it.
The text was updated successfully, but these errors were encountered: