angular / angular/components

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

Open
#30,160 1 comment 0 reactions 0 assignees View on GitHub
area: cdk/testing P3
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

### 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

Contributor guide

Open the contributing guide

Research direction

Start with the MatInputTestHarness behavior described in the issue and run the linked StackBlitz reproduction, based on the modified Material input example. Verify the failing event spies around setValue(), including the focus and blur attempt. Done means the expected change handler runs and both reproduction tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.