Skip to content

Conversation

@eps1lon
Copy link
Collaborator

@eps1lon eps1lon commented Nov 18, 2025

Closes #30580
Closes #34295

React's automatic form reset made it more apparent that controlled select is not working with form.reset(). Each form associated element has its own reset algorithm.

For <input>, that's reading back the value attribute which is why syncing the attribute value is critical for reset.

According to the spec, <select> reads from the selected attribute (https://html.spec.whatwg.org/multipage/form-elements.html#the-select-element) which is reflected from the defaultSelected DOM property. I adjusted the warning for setting selected via prop to make it clear why doing that is problematic.

Test plan

@meta-cla meta-cla bot added the CLA Signed label Nov 18, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Nov 18, 2025
@react-sizebot
Copy link

react-sizebot commented Nov 18, 2025

Comparing: 0972e23...cacd6ba

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js +0.03% 608.16 kB 608.32 kB +0.03% 107.65 kB 107.68 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js +0.02% 666.18 kB 666.34 kB +0.03% 117.35 kB 117.39 kB
facebook-www/ReactDOM-prod.classic.js +0.02% 693.31 kB 693.47 kB +0.03% 121.98 kB 122.01 kB
facebook-www/ReactDOM-prod.modern.js +0.02% 683.73 kB 683.90 kB +0.03% 120.36 kB 120.40 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
test_utils/ReactAllWarnings.js +0.22% 66.51 kB 66.66 kB +0.12% 16.74 kB 16.76 kB

Generated by 🚫 dangerJS against cacd6ba

@eps1lon eps1lon changed the title Add fixture [react-dom] Keep controlled <select> value on form reset Nov 18, 2025
@eps1lon eps1lon changed the title [react-dom] Keep controlled <select> value on form reset [react-dom] Keep controlled <select> value on form reset Nov 18, 2025
@eps1lon eps1lon marked this pull request as ready for review November 18, 2025 14:50
@eps1lon eps1lon force-pushed the sebbie/controlled-select branch from 05867ea to cacd6ba Compare November 18, 2025 16:04
@billyjanitsch
Copy link
Contributor

@eps1lon thanks for this PR. I'm glad to see this fixed!

Checkboxes and radio inputs are also affected. (See #31695.) Would it be straightforward to fix them in the same way?

@eps1lon
Copy link
Collaborator Author

eps1lon commented Nov 19, 2025

I'll follow-up with that once this is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[React 19] Controlled <select> component is subject to automatic form reset

3 participants