mat-selection-list list-options is not updated when formControl for mat-selection-list is updated with setValue
- 主要言語
- TypeScript
- スター
- 25k
- フォーク
- 6.8k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 91
説明
#### What is the expected behavior?
Checkboxes should update
#### What is the current behavior?
Checkboxes do not update.
#### What are the steps to reproduce?
**editor.componenet.html**
```html
{{ role.attributes.name }}
```
**editor.component.ts (onInit)**
```javascript
this.form = this.fb.group({
role: [[...this.user.attributes.role], Validators.required],
});
```
`this.user.attributes.role` is an array of string.
**I tried**
**editor.component.ts**
```javascript
ngAfterContentInit() {
this.form.patchValue({
'role': [...this.user.attributes.role]
});
}
```
**I also tried**
**editor.component.ts**
```javascript
ngAfterContentInit() {
setTimeout(() => {
this.form.patchValue({
'role': [...this.user.attributes.role]
});
console.log(this.form.value.role);
}, 1000);
}
```
Note that I'm getting `roles` with an observable :
**editor.component.ts**
```javascript
combineLatest(
// Others observables ...
this.jsonApi.all('roles').pipe(map(document => document.data)),
).subscribe(([firms, langs, roles]) => {
// Others observables ...
this.roles = roles;
});
```
#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 7.x.x
Material 7.x.x
#### Is there anything else we should know?
I know there's a [ticket](https://github.com/angular/material2/issues/9085) about this, but it's closed and no one replies
コントリビューションガイド
調査の方向性
editor.component.html と editor.component.ts を使用し、Angular 7 の mat-selection-list、非同期のロール、formControl setValue または patchValue を使って問題を再現します。まず mat-selection-list と mat-list-option の value の伝播を追跡します。完了条件は、フォームの更新後にチェックボックスが更新された文字列配列を反映することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, typescript
- 領域
- frontend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100