Skip to content

bug(autocomplete): harness does not fire focusin event #23757

@Nosfistis

Description

@Nosfistis

Reproduction

Use StackBlitz to reproduce your issue:

Steps to reproduce:

  1. Create an autocomplete test with harness
  2. 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

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/testing

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions