Skip to content

Conversation

@tharani-2006
Copy link

What changes are being made and why?

This PR fixes the issue where a type="number" input using useActionState clears its value when pressing Enter.

Previously, the input named "From:" would get cleared, even though the defaultValue contained the typed number.

The expected behavior is that the number input should behave like other inputs (e.g., "Name"), preserving its value after hitting Enter.

This change ensures that number inputs retain the typed value after form submission via Enter.


How the changes have been QAed?

Tested locally in a React 19 environment.

Typed a number in the "From:" input and pressed Enter → value remains visible as expected.

Confirmed "Name" input behavior is unchanged.

Verified that the form submission still works correctly and useActionState continues to receive updated values.

… used with useActionState

- Modified setDefaultValue function to allow updating defaultValue for focused number inputs when the value has changed
- This ensures that form actions can properly update the visual value of number inputs after completion
- Added comprehensive test to verify the fix works correctly
- Resolves issue facebook#33667

The fix allows defaultValue updates for focused number inputs when the value has actually changed, which is necessary when form actions complete and need to update the visual value. This maintains backward compatibility while fixing the specific issue with useActionState.
@meta-cla
Copy link

meta-cla bot commented Oct 25, 2025

Hi @tharani-2006!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@meta-cla
Copy link

meta-cla bot commented Oct 25, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Oct 25, 2025
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.

1 participant