Skip to content
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

Merged
merged 1 commit into from
Dec 2, 2017

Conversation

nhunzaker
Copy link
Contributor

@nhunzaker nhunzaker commented Dec 1, 2017

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

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.
nhunzaker added a commit that referenced this pull request Dec 1, 2017
@@ -235,10 +236,7 @@ function handleControlledInputBlur(inst, node) {
}

// If controlled, assign the value attribute to the current value on blur
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment misleading now?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@gaearon
Copy link
Collaborator

gaearon commented Dec 1, 2017

Is there any difference in observable behavior here? Does this need a fixture?

@nhunzaker
Copy link
Contributor Author

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.

@nhunzaker
Copy link
Contributor Author

Tested in:

  • Chrome 59, 42
  • Safari 11, 7
  • IE 11, 10, 9
  • Edge 16
  • Firefox 58
  • Firefox 52 (ESR)

@gaearon gaearon merged commit 8ce5367 into master Dec 2, 2017
nhunzaker added a commit that referenced this pull request Dec 2, 2017
gaearon pushed a commit that referenced this pull request Dec 4, 2017
…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
@gaearon gaearon deleted the synchronize-number-blur branch January 5, 2018 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants