Skip to content

Controlled TextField resets on form reset #6555

@tilpoe

Description

@tilpoe

Provide a general summary of the issue here

I don't know if it's a bug or expected behaviour, but i didn't find anything on that matter.
To my understanding, controlled form fields shouldn't be reset when one resets their corresponding form, which works if one is using a simple input element. But if I use a controlled TextField, the input gets reset.

🤔 Expected Behavior?

Controlled TextField (or any other field) shouldn't be reset when resetting the corresponding form.

😯 Current Behavior

Controlled TextField (or any other field) gets reset when resetting the corresponding form.

💁 Possible Solution

No response

🔦 Context

In React 19 a form (and therefore uncontrolled form fields) gets automatically reset after submitting a server action (which apparently is just the same as calling form.reset() see: facebook/react#28804). So if rac components get reset although they are controlled, i would have to work around the new react 19 behaviour by returning the previous values from the action, which would be kind of unneccessary work and also not suggested by the react team (facebook/react#28491 (comment)).

🖥️ Steps to Reproduce

The behaviour after submitting a server action is the same as calling form.reset(), which is why i did this manually in this example to avoid having to set up next.js. You can just input some text in both fields and press the reset button. The RAC Component is reset, the default input is not.

https://codesandbox.io/p/sandbox/relaxed-nightingale-5j5yfm?file=%2Fsrc%2FApp.js

Version

1.2.1

What browsers are you seeing the problem on?

Chrome, Safari

If other, please specify.

No response

What operating system are you using?

macOS 14.3.1 (23D60)

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions