-
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
Use the same value synchronization function on number blur #11746
Conversation
I updated ReactDOMInput.synchronizeDefaultValue such that it assignes the defaultValue property instead of the value attribute. I never followed up on the ChangeEventPlugin's on blur behavior.
@@ -235,10 +236,7 @@ function handleControlledInputBlur(inst, node) { | |||
} | |||
|
|||
// If controlled, assign the value attribute to the current value on blur |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment misleading now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Though the controlled input guard triggers above this line. It is not apart of this specific block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you asked! So we could probably improve it. Something like:
// Focused number inputs do not update their defaultValue on change. This
// avoids unexpected value changes in Chrome while the user is typing. On blur,
// we need to synchronize the defaultValue to match standard input behavior.
Is there any difference in observable behavior here? Does this need a fixture? |
I don't think so. We just need to test the number input fixtures. |
Tested in:
|
…1741) * Ensure value and defaultValue do not assign functions and symbols * Eliminate assignProperty method from ReactDOMInput * Restore original placement of defaultValue reservedProp * Reduce branching. Make assignment more consistent * Control for warnings in symbol/function tests * Add boolean to readOnly assignments * Tweak the tests * Invalid value attributes should convert to an empty string * Revert ChangeEventPlugin update. See #11746 * Format * Replace shouldSetAttribute call with value specific type check DOMProperty.shouldSetAttribute runs a few other checks that aren't appropriate for determining if a value or defaultValue should be assigned on an input. This commit replaces that call with an input specific check. * Remove unused import * Eliminate unnecessary numeric equality checks (#11751) * Eliminate unnecessary numeric equality checks This commit changes the way numeric equality for number inputs works such that it compares against `input.valueAsNumber`. This eliminates quite a bit of branching around numeric equality. * There is no need to compare valueAsNumber * Add test cases for empty string to 0. * Avoid implicit boolean JSX props * Split up numeric equality test to isolate eslint disable command * Fix typo in ReactDOMInput test * Add todos * Update the attribute table
I updated ReactDOMInput.synchronizeDefaultValue such that it assignes
the defaultValue property instead of the value attribute. I never
followed up on the ChangeEventPlugin's on blur behavior.
Follow-up from https://github.com/facebook/react/pull/11741/files
Fixes #8395