ionic-team / ionic-team/ionic-framework

feat: Ionic form controls should support `defaultValue` and `defaultChecked` properties

Đang mở
#28,193 6 bình luận 1 reaction 0 người được giao Xem trên GitHub
package: core type: feature request
Ngôn ngữ chính
TypeScript
Star
52.7k
Fork
13.3k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
51

Mô tả

### 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!

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.