angular / angular/components

bug(mat-radio-group): Programmatic changes are not reflected in the form model

オープン
#24,546 コメント 3 件 リアクション 1 件 担当者 0 名 GitHub で見る
area: material/radio P4
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。