Repository navigation
Conversation
|
Comparing: 59aff3e...180acbe Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) Generated by sizebot against 180acbe |
Contributor
Author
|
hi @eps1lon would you also take a look at this when you have a moment? thanks for reviewing! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The HTML form reset algorithm restores a checkbox or radio from its
checkedcontent attribute, i.e.defaultChecked. React stops updating that attribute after mount, so a controlled input is reset as if it were uncontrolled, both byform.reset()and by the automatic reset that runs after a formaction:updateInputalready keeps thevalueattribute in sync with thevalueprop for exactly this reason, andinitInputwrites thecheckedattribute from thecheckedprop on mount. Only the update path was missing, so a controlled checkbox reverts to whatever it rendered with initially while a controlled text input in the same form keeps its value.This applies the cascade the
checkedproperty already uses to the attribute as well, guarded against redundant writes the waysetDefaultValueis.disableInputAttributeSyncingis unchanged: in that mode the attribute stays driven solely bydefaultChecked.<select>has the same problem and is fixed separately in #35168.Fixes #31695
How did you test this change?
One test per file, both failing on
main. InReactDOMInput-test.js, a controlled checkbox and radio keep their checkedness acrossform.reset()both when going unchecked to checked and back, while an uncontrolled checkbox in the same form is still reset. InReactDOMForm-test.js, the automatic reset that runs after a formactionno longer clears them.yarn testandyarn test --prodonpackages/react-domyarn test-stable,yarn test-www,yarn test-www --variant=false,yarn test-classic,yarn test-classic --variant=falseon the touched suitesyarn test(full suite)yarn lincyarn prettier-checkyarn flow dom-nodeandyarn flow dom-browser