[TextField] Uncontrolled Input components do not fully reset when inside 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/s/admiring-ishizaka-yjy2wk?file=/Demo.tsx
Link to live example using state: https://codesandbox.io/s/charming-grothendieck-r9zw8y?file=/Demo.tsx
Current behavior 😯
When I use certain components like radio buttons, checkbox, switch, textfiled, select, and autocomplete, I can't clear the value by pressing the reset button. When I click the reset button, the text inside the textfield gets cleared, but it will not shrink off the label.
If I use the above components with states then it will work properly (refer second codesandbox example above).
Expected behavior 🤔
Changes in the value of the above components will get reset 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: macOS 13.2.1
Binaries:
Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.17.1/bin/yarn
npm: 9.6.7 - ~/.nvm/versions/node/v18.17.1/bin/npm
Browsers:
Chrome: 116.0.5845.187
Edge: Not Found
Safari: 16.3
npmPackages:
@emotion/react: ^11.10.8 => 11.10.8
@emotion/styled: ^11.10.8 => 11.10.8
@mui/base: 5.0.0-alpha.127
@mui/core-downloads-tracker: 5.12.2
@mui/lab: ^5.0.0-alpha.128 => 5.0.0-alpha.128
@mui/material: ^5.12.2 => 5.12.2
@mui/private-theming: 5.12.0
@mui/styled-engine: 5.12.0
@mui/system: ^5.12.1 => 5.12.1
@mui/types: 7.2.4
@mui/utils: 5.12.0
@mui/x-data-grid: 6.0.3 => 6.0.3
@types/react: ^18.2.0 => 18.2.0
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: ^5.0.4 => 5.0.4
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 with Demo.tsx in the linked CodeSandbox examples and reproduce the reset-button behavior for the uncontrolled radio, checkbox, switch, text field, select, and autocomplete components. Compare the uncontrolled and stateful examples. Done means the reset button clears each component's value and associated UI state, including the text-field label shrinking.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100