MatAutocomplete does not always emit opened event
- Lenguaje dominante
- TypeScript
- Estrellas
- 25k
- Forks
- 6.8k
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 91
Descripción
#### 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.
Guía de contribución
Línea de trabajo
Empieza con MatAutocompleteTrigger:open y _subscribeToClosingActions en src/lib/autocomplete/autocomplete-trigger.ts, y después inspecciona MatAutocomplete:_setVisibility en src/lib/autocomplete/autocomplete.ts. Ejecuta la reproducción vinculada de StackBlitz y verifica que escribir después de añadir opciones emita opened cuando el panel se haga visible, sin introducir emisiones inesperadas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- angular, typescript
- Área
- frontend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 55/100