You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Name1 is using md-error. Error will only show after control been touched.
Name2 is using an old workaround with md-hint. It can show error directly when dirty.
What is the use-case or motivation for changing an existing behavior?
For 99% of the time I believe the current implementation is the best behavior.
However, for special cases, you will need to be able to modify when errors are shown. For example instantly as the example from the Angular documentation.
Which versions of Angular, Material, OS, browsers are affected?
Angular v4.0.3
Material v2.0.0-beta.3
Is there anything else we should know?
I assume my request is not currently possible as my question on StackOverflow did not get any suggested answers.
@jelbourn, since you labeled #4750 as needing discussion, I'd like to illustrate my motivation for pushing for the change. In this plunker you can see that validation must be performed at a group level since the password and confirm controls are dependent on one another. Per @kara's suggestion, this is the best (if not only) way to achieve sibling validation.
Two workarounds must be put into place to emulate the correct behavior:
class.mat-input-invalid must be bound to a custom error state matcher
An <md-hint> must be styled like an <md-error>, thus losing entrance animations, and you must also bind it to the custom error state matcher with *ngIf
I recognize that this should be reused in md-select, but I'd hate to have to wait until #4672, when the tiny amount of logic could be copied as soon as #4754 lands. Would a typescript mixin work for this?
I agree that, conceptually, you should be able to change when the error shows. I'm just not sure this is a good way to go about doing that customization. Having it as an input on the control means that there's no good way to configure the behavior app-wide, which I think would be important.
Activity
HopScotch47 commentedon Apr 24, 2017
Instead of configuring the whole behaviour to trigger a special case, you could simply do this:
for the control in question. This at least is what I do in such cases.
jelbourn commentedon May 1, 2017
@kara might also have some thoughts on this
willshowell commentedon May 25, 2017
@jelbourn, since you labeled #4750 as needing discussion, I'd like to illustrate my motivation for pushing for the change. In this plunker you can see that validation must be performed at a group level since the
passwordandconfirmcontrols are dependent on one another. Per @kara's suggestion, this is the best (if not only) way to achieve sibling validation.Two workarounds must be put into place to emulate the correct behavior:
class.mat-input-invalidmust be bound to a custom error state matcher<md-hint>must be styled like an<md-error>, thus losing entrance animations, and you must also bind it to the custom error state matcher with*ngIfI recognize that this should be reused in md-select, but I'd hate to have to wait until #4672, when the tiny amount of logic could be copied as soon as #4754 lands. Would a typescript mixin work for this?
jelbourn commentedon May 25, 2017
I agree that, conceptually, you should be able to change when the error shows. I'm just not sure this is a good way to go about doing that customization. Having it as an input on the control means that there's no good way to configure the behavior app-wide, which I think would be important.
willshowell commentedon May 25, 2017
Dang, had not considered global config and I agree
angular-automatic-lock-bot commentedon Sep 6, 2019
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.