angular / angular/components

bug(autocomplete): DisplayWith retriggering + Programmatical value selection

オープン
#28,161 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る
area: material/autocomplete P3
主要言語
TypeScript
スター
25k
フォーク
6.8k
平均マージ
1日 8時間
マージ済み PR(30日)
91

説明

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

1. It's impossible to retrigger displayWith method (only when resetting form value).
2. Initial data is not displayed on dropdown with checkmark symbol, when property is binded. After selection all is working
2.1 When changing value programatically, checkmark is displayed on wrong selection.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/zkwk2u
Steps to reproduce:
1. Change language
2. Value is not translated + not possible trigger displayWith. I tried different things, even updateValueAndValidity on formControl, which should really execute ValueChanges. Only when changing property value with setValue, it triggers displayWith method. With this approach I saw second problem, with programmatically changing control value.

1. Open link, selected value is displayed correctly with displayWith
2. Open dropdown no selection is displayed.
3. Select new value (first value) from dropdown (value is displayed correctly with check mark)
4. Click button (it changes value to 3, 3rd selection)
5. Value change is triggered and input shows correct data.
6. Open dropdown, it still shows wrong selection

### Expected Behavior

1. It's possible to trigger programmatically displayWith
2. Programmatically selected value + initial value is displayed correctly

### Actual Behavior

1. When already displayed value with displayWith, then this is not possible to change
2. Selection is not shown or shown wrongly

### Environment

- Angular: 17.0.0
- CDK/Material: 17.0.1
- Browser(s):
- Operating System (e.g. Windows, macOS, Ubuntu):

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

リンクされている StackBlitz の再現から始め、displayWith、初期値、プログラムによる setValue の変更に関する Angular Material autocomplete の動作を調査します。displayWith をプログラムで再度トリガーでき、ドロップダウンのチェックマークが初期選択値とプログラムで選択された値の両方を正しく追跡できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angular, typescript
領域
frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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