-
Notifications
You must be signed in to change notification settings - Fork 47.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Migrate input value change fix from 16.0.0-alpha #7303
Conversation
hey there, So the reason this change is in 16 is because it has some breaking changes in it. My changes were actually done before 15 was released :P but deferred to 16 intentionally |
Ah bummer. Think the only resolution for issues like #3659 is to simply wait for React 16? |
Closing since we're not going to backport any breaking changes 👍 |
I've mentioned this before in other places but this need not be a breaking change. |
@jquense I'm interested. What do you have in mind? |
Sorry @jquense, I was basing this on your comment
Can you link to previous discussion on how to make this non-breaking? |
sure thing here it is: #5746 (comment) The more i've sat on this I don't actually think this is even a reasonable breaking change it makes |
Not having looked at #7642, this sounds intentional. We don't want to go through the code that normalizes events for different browsers – that's exactly the difference between Simulate and SimulateNative. To fix the issue here, would it make sense to track the current value on |
its definitely intentional that The PR (from me) that this is backporting, does solve the issue of needing focus on inputs for them to work, by doing something similar to moving the value state to consider this example: let inputNode = renderInput(<input onChange={changeSpy}/>);
inputNode.value = 'foo'; // internal state tracking sets "current" value to 'foo';
SimulateNative.change(inputNode); The |
you can see the issue here: https://github.com/facebook/react/pull/5746/files#diff-2bead3a73555ca476b3dedf1f31fbb93R81 and the moved state tracking logic here: https://github.com/jquense/react/blob/669e3dff96234ff4ec5626b93f50877b8889444d/src/renderers/dom/client/inputValueTracking.js hooks into DOMInput here: https://github.com/jquense/react/blob/669e3dff96234ff4ec5626b93f50877b8889444d/src/renderers/dom/shared/ReactDOMComponent.js#L486 The older ie8-9 logic was left alone, to not stir the pot anymore :P |
Is suppressing events due to setting .value the only reason we need the .value setter? I wonder if we can get rid of it. Maybe we need it though since you could imagine setting .value from within an onChange. :| |
i wish :/ but no, if you don't track imperative value sets but also try and dedupe the events you run the risk of missing legitimate value changes. Consider:
The last foo won't fire because the internal tracking never saw that the value changed. Granted that's an unlikely case, but the cost of missing any value change is high, as seen by the slew of IE issues about it I thought maybe if react just said "no" to supporting imperative value sets we;d be ok removing that, but you still run afoul of autocomplete, password managers, etc. |
This PR backports work done by @jquense to fix several event issues for React 15.x. Additionally, addressing issue #3659. It is a blend of his work with newer updates from master.
Should fix #3659, and a couple of others.