ionic-team / ionic-team/ionic-framework
feat: Ionic form controls should support `defaultValue` and `defaultChecked` properties
- Vorherrschende Sprache
- TypeScript
- Sterne
- 52.7k
- Forks
- 13.3k
- Ø Merge
- 1 T. 15 Std.
- Gemergte PRs (30 T.)
- 51
Beschreibung
### Prerequisites
- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already report this problem, without success.
### Ionic Framework Version
v7.x
### Current Behavior
When using uncontrolled form inputs, it is not possible to set default values. The `defaultValue` prop is ostensibly available according to the types, but setting it does not result in the `value` prop initially getting set during the first render. This differs from [React's expected behavior for providing an initial value](https://react.dev/reference/react-dom/components/input#providing-an-initial-value-for-an-input).
### Expected Behavior
`defaultValue` is initially set to the input's value on first render
### Steps to Reproduce
1. Add `defaultValue` as a prop to an input
2. Render the component
3. Value is not set
### Code Reproduction URL
https://stackblitz.com/edit/vxete3
### Ionic Info
**Ionic**:
Ionic CLI : 5.4.16
**Utility**:
cordova-res : not installed
native-run : not installed
**System**:
NodeJS : v16.20.0
npm : 9.4.2
OS : Linux 5.0
(this is from Stackblitz)
### Additional Information
Technically `defaultValue` is not listed as a property in the Ionic docs (https://ionicframework.com/docs/api/input#properties), but it is an accepted value according to the component's types (`React.ForwardRefExoticComponent, "style"> & StyleReactProps & React.RefAttributes>`).
If there's another way to use uncontrolled inputs in @ionic/react, please let me know!
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.