MatAutocomplete does not always emit opened event
- 主要言語
- TypeScript
- スター
- 25k
- フォーク
- 6.8k
- 平均マージ
- 1日 8時間
- マージ済み PR(30日)
- 91
説明
#### Bug, feature request, or proposal:
Bug
#### What is the expected behavior?
The `opened` event should be sent when the panel is open.
#### What is the current behavior?
When an autocomplete panel is initialized with no options, but they are added later, the `opened` event is never sent.
#### What are the steps to reproduce?
Open [https://stackblitz.com/edit/bug-autocomplete-opened](https://stackblitz.com/edit/bug-autocomplete-opened), then type something to open the autocomplete panel.
#### What is the use-case or motivation for changing an existing behavior?
The event is used to obtain a reference to the autocomplete panel’s HTML element, as soon as it is open.
#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
- Material 6.4.7
- Angular 6.1.0
#### Is there anything else we should know?
- See [MatAutcompleteTrigger:open](https://github.com/angular/material2/blob/2e4a51180b0074d59c1584c82fb8959f52660124/src/lib/autocomplete/autocomplete-trigger.ts#L609) the overlay is created but the event is never emitted because is no `MatOption` available.
- See [MatAutocompleteTrigger:_subscribeToClosingActions](https://github.com/angular/material2/blob/2e4a51180b0074d59c1584c82fb8959f52660124/src/lib/autocomplete/autocomplete-trigger.ts#L495), when changes are detected, the panel becomes visible but no event is emitted.
A possible fix is to emit events in [MatAutocomplete:_setVisibility](https://github.com/angular/material2/blob/2e4a51180b0074d59c1584c82fb8959f52660124/src/lib/autocomplete/autocomplete.ts#L196), but it’ll introduce a new (and possible unexpected) behavior to the component.
コントリビューションガイド
調査の方向性
src/lib/autocomplete/autocomplete-trigger.ts の MatAutocompleteTrigger:open と _subscribeToClosingActions から始め、続いて src/lib/autocomplete/autocomplete.ts の MatAutocomplete:_setVisibility を調べます。リンクされている StackBlitz の再現を実行し、オプションが追加された後に入力すると、パネルが表示されたときに opened が emit され、予期しない emission が導入されないことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, typescript
- 領域
- frontend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 55/100