Description
Reproduction
Use StackBlitz to reproduce your issue:
Steps to reproduce:
- Create an autocomplete test with harness
- Focus the autocomplete via
MatAutocompleteHarness.focus()
Expected Behavior
The input element is focused and the autocomplete options are rendered. They can also be queried in the DOM (e.g. check that an element with text "Choice A" exists). Dispatching focus
via a harness should also dispatch focusin
beforehand, so that it emulates properly the browser behavior.
Actual Behavior
The input element is focused, but the options are not open. This is because the autocomplete harness fires the focus
event, while mat-autocomplete-trigger
listens for focusin
events, which are not triggered via the JS focus
event.
Environment
- Angular: 12.2
- CDK/Material: 12.2
- Browser(s): Chrome 96
- Operating System (e.g. Windows, macOS, Ubuntu): Windows