angular / angular/components

feat(inputs): Add `[readonly]` property to input components

未关闭
#27,955 9 条评论 16 个 reaction 已指派 0 人 在 GitHub 查看
feature P4
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Feature Description

Right now input components (checkbox, chips, datepicker, form field, radio button, select, slider) have `[disabled]` property. Only `matInput` directive has `[readonly]`.

`[disabled]` property conflicts with the `[formControl]` directive, which has a [property with the same name](https://github.com/angular/angular/blob/main/packages/forms/src/directives/reactive_directives/form_control_directive.ts#L72).

So if you use `[formControl]` with the components listed above, it is not possible to use their `[disabled]` property.

### Use Case

`[disabled]` controls [will not be included](https://github.com/angular/angular/blob/main/packages/forms/src/model/abstract_model.ts#L409) in `form.value` - sometimes you need to render an input element as read-only but still send its value to the server.

贡献指南

打开贡献指南

调研方向

首先,将 matInput 指令上现有的 [readonly] 行为与 checkbox、chips、datepicker、form field、radio button、select 和 slider 组件进行比较。阅读链接的 FormControlDirective 属性和 AbstractControl 文档,以了解 disabled/value 的交互。完成的标准是每个列出的组件都支持 [readonly],且不会将其值从 form.value 中排除。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。