[material-ui] Uncontrolled TextField components fail to reset, and their floating labels don't return to default in a <form> with a reset button
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Steps to reproduce 🕹
Link to live example without using state: https://codesandbox.io/p/sandbox/cranky-chihiro-vc6pq4
Link to live example using state: https://codesandbox.io/p/sandbox/upbeat-joana-2n4dz9
Current behavior 😯
-
When using TextField component after clearing First TextField (First name), Pressing the reset button in a form overlaps default value of TextField with the placeholder (First name).
-
When using TextField component after entering some value in second TextField (Last name), Pressing the reset button in a form only reverts value of the TextField, but floating label (Last name) of TextField does not set back to its default position.
-
When using TextField component after selecting value in second TextField (Last name) from suggestions (previously entered values), Pressing the reset button in a form reverts value of the TextField and floating label returns to its default position while in above case it does not.
If I use TextField with state then it will work properly for all above cases.
Expected behavior 🤔
Value of the TextField will get reset to its default value and floating label (placeholder) also returns to its default position while clicking on the reset button when we are not using the state (for the first codesandbox).
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Chromium (120.0.2210.77)
npmPackages:
@emotion/react: ^11.11.1 => 11.11.1
@emotion/styled: ^11.11.0 => 11.11.0
@mui/base: 5.0.0-beta.28
@mui/core-downloads-tracker: 5.15.1
@mui/material: ^5.15.1 => 5.15.1
@mui/private-theming: 5.15.1
@mui/styled-engine: 5.15.1
@mui/system: 5.15.1
@mui/types: 7.2.11
@mui/utils: 5.15.1
@types/react: ^18.2.45 => 18.2.45
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: ^4.9.5 => 4.9.5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the uncontrolled and stateful cases in the two linked CodeSandbox examples, focusing on form reset behavior for TextField values and floating labels. Done means an uncontrolled TextField resets to its default value and its label returns to the default position in all described cases, while the existing stateful behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100