Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(MatInputTestHarness): setValue does not trigger "change" event #30160

Open
1 task
scottg521 opened this issue Dec 10, 2024 · 1 comment
Open
1 task

bug(MatInputTestHarness): setValue does not trigger "change" event #30160

scottg521 opened this issue Dec 10, 2024 · 1 comment
Labels
needs triage This issue needs to be triaged by the team

Comments

@scottg521
Copy link

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

According to the documentation, the MatInput component emits a "change" event when the value changes. However, the test harness does not emit this event after "setValue()". See the stackblitz.

I have tried using focus() to focus the component before setting the value, then blur() to remove focus, which is what triggers "change" in the application, and there is still no "change" event.

Reproduction

StackBlitz link: https://stackblitz.com/edit/phfedq5f?file=src%2Fexample%2Finput-harness-example.html
Steps to reproduce:

  1. modified example test from https://material.angular.io/components/input/examples should run automatically
  2. two tests fail because the event spy is not called

Expected Behavior

You should be able to trigger the expected event with the test harness.

Actual Behavior

Expected code associated with (change) to run.

Environment

  • Angular: 19
  • CDK/Material: 19
  • Browser(s): chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows, macOs
@scottg521 scottg521 added the needs triage This issue needs to be triaged by the team label Dec 10, 2024
@scottg521
Copy link
Author

setValue does trigger the 'input' event, so maybe 'blur' should trigger the change event. I have worked around by getting the host element and dispatching the change event, but it still seems that the documented event should be able to be triggered from the test harness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

1 participant