Skip to content

fix(datepicker): placeholder not floating when an invalid value is typed in #8603

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

Merged

Conversation

crisbeto
Copy link
Member

Fixes the datepicker input's placeholder not floating if the user types in an invalid value. This was due to the datepicker's value being parsed to null which the form field inferred as empty. These changes switch to always check the DOM element, rather than the actual control value.

Fixes #8575.

@crisbeto crisbeto requested a review from mmalerba as a code owner November 22, 2017 21:47
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 22, 2017
@@ -264,13 +264,6 @@ export class MatInput implements MatFormFieldControl<any>, OnChanges, OnDestroy,
return this._neverEmptyInputTypes.indexOf(this._type) > -1;
}

/** Checks whether the input is invalid based on the native validation. */
protected _isBadInput() {
Copy link
Contributor

Choose a reason for hiding this comment

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

can't get rid of this, it's needed for cases where the browser considers the value invalid, like this: https://jsfiddle.net/3bbhk7ka/

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, good to know. I've re-added it.

…ped in

Fixes the datepicker input's placeholder not floating if the user types in an invalid value. This was due to the datepicker's value being parsed to `null` which the form field inferred as empty. These changes switch to always check the DOM element, rather than the actual control value.

Fixes angular#8575.
@crisbeto crisbeto force-pushed the 8575/datepicker-placeholder-float branch from dd3987a to e0bff78 Compare November 24, 2017 16:18
@mmalerba mmalerba added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Nov 27, 2017
@mmalerba mmalerba added this to the 5.0 milestone Nov 27, 2017
@mmalerba mmalerba added the P2 The issue is important to a large percentage of users, with a workaround label Nov 27, 2017
@tinayuangao tinayuangao merged commit f0789eb into angular:master Dec 1, 2017
@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 Sep 7, 2019
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 P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Datepicker hint displayed on top of value on incorrect input
4 participants