Skip to content

bug(MatInputHarness): Does not properly set negative value on form control for <input type="number"> #24414

Closed
@ccosmincc

Description

@ccosmincc

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

Setting the value of a number input to a negative value using MatInputHarness.setValue sets the value to the opposite (positive) on the form control bound to the input.

Seems related to #19314

Reproduction

Steps to reproduce:

  1. use a mat-form-field with formControl
  2. in the test, set a negative value using the MatInputHarness.setValue('-3')
  3. formControl value will be positive (3), while MatInputHarness.getValue() will return the correct negative value (-3)

https://stackblitz.com/edit/angular-13-starter-x-3avuxy?file=src%2Fapp%2Fapp.component.spec.ts (run ng test)

Expected Behavior

Form control value should be set to a negative value

Actual Behavior

Form control value is set to a positive value

Environment

  • Angular: ~13.1.0
  • CDK/Material: ^13.1.1

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions