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

fix(cdk/testing): unable to assign value to number inputs using sendKeys #22395

Merged
merged 1 commit into from
Apr 13, 2021

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Apr 4, 2021

Currently the UnitTestElement simulates typing into an input by assigning the value character-by-character and dispatching fake events along the way. The problem is that for input types that require the value to be in a particular format (e.g. number, color, date) doing so will temporarily assign an invalid value which will be rejected by the browser with a warning like The specified value "12." cannot be parsed, or is out of range..

This can become a problem for some common use cases like the ReactiveFormsModule where a directive might be keeping track of the value by looking at the DOM inside of an input event (e.g. the FormControl directive does this).

These changes resolve the issue by looking at the type of the input, and if it's a type that requires a specific format, we assign the value immediately.

Fixes #22129.

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release labels Apr 4, 2021
@crisbeto crisbeto requested a review from mmalerba April 4, 2021 09:01
@google-cla google-cla bot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Apr 4, 2021
Currently the `UnitTestElement` simulates typing into an input by assigning the value character-by-character and dispatching fake events along the way. The problem is that for input types that require the value to be in a particular format (e.g. `number`, `color`, `date`) doing so will temporarily assign an invalid value which will be rejected by the browser with a warning like `The specified value "12." cannot be parsed, or is out of range.`.

This can become a problem for some common use cases like the `ReactiveFormsModule` where a directive might be keeping track of the value by looking at the DOM inside of an `input` event (e.g. the `FormControl` directive does this).

These changes resolve the issue by looking at the type of the input, and if it's a type that requires a specific format, we assign the value immediately.

Fixes angular#22129.
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Apr 7, 2021
@mmalerba mmalerba merged commit 2f177b6 into angular:master Apr 13, 2021
mmalerba pushed a commit that referenced this pull request Apr 13, 2021
…eys (#22395)

Currently the `UnitTestElement` simulates typing into an input by assigning the value character-by-character and dispatching fake events along the way. The problem is that for input types that require the value to be in a particular format (e.g. `number`, `color`, `date`) doing so will temporarily assign an invalid value which will be rejected by the browser with a warning like `The specified value "12." cannot be parsed, or is out of range.`.

This can become a problem for some common use cases like the `ReactiveFormsModule` where a directive might be keeping track of the value by looking at the DOM inside of an `input` event (e.g. the `FormControl` directive does this).

These changes resolve the issue by looking at the type of the input, and if it's a type that requires a specific format, we assign the value immediately.

Fixes #22129.

(cherry picked from commit 2f177b6)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug on MatInputHarness when setting decimal values to input of type "number"
3 participants