bug(mat-radio-group): Programmatic changes are not reflected in the form model
- 主要语言
- TypeScript
- 星标
- 25k
- 派生
- 6.8k
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 91
描述
### Description
When setting `value` on `matRadioGroup`, the visually selected radio button updates, but the form model does not.
Looking at the material source code, the form model is only updated (via `_controlValueAccessorChangeFn`) via the radio input's `change` event. Is this intentional?
### Reproduction
See Stackblitz: https://stackblitz.com/edit/angular-ivy-hpd53z?file=src%2Fapp%2Fapp.component.ts
Steps to reproduce:
1. Select a radio button by clicking it - observe that the form model updates accordingly
2. Select a radio button that is not green
3. Click the 'Force Green' button, which programmatically sets the `value` to green
### Expected Behavior
The `color` value in the form model updates
### Actual Behavior
The `color` value in the form model does not update
### Environment
- Angular: 13.2.0
- CDK/Material: 13.2.5
- Browser(s): Chrome
- Operating System: Windows
贡献指南
调研方向
从链接的 StackBlitz 复现和 issue 中描述的 mat-radio-group 源码开始,跟踪以编程方式更改值后如何传递到表单模型。当将组值设置为 green 能更新表单模型的 color 值,同时现有的点击行为继续正常工作时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- angular, typescript
- 领域
- frontend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100