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

touched broken for matInput #11

Closed
artem-v-shamsutdinov opened this issue Dec 7, 2017 · 3 comments
Closed

touched broken for matInput #11

artem-v-shamsutdinov opened this issue Dec 7, 2017 · 3 comments

Comments

@artem-v-shamsutdinov
Copy link

artem-v-shamsutdinov commented Dec 7, 2017

Hello,

Using ng-trim with Angular Material appears to break the setting of the "touched" property of the input.

Here is an example:

https://stackblitz.com/edit/angular-68fg1b?file=index.html

The field has an error message defined that should show if the field has the "required" error and has been touched. However the touched property does not get updated when I click on the field (or when I enter data into it).

I'll gather more info as I debug ...

Thanks, :)

@artem-v-shamsutdinov
Copy link
Author

artem-v-shamsutdinov commented Dec 7, 2017

So, just injecting NgControl as a member variable into the directive appears to fix the problem. :)

Here is the working example:

https://stackblitz.com/edit/angular-vxfwnt

I did have to move providers to the module level and add a NG_VALIDATORS provider (as described here: https://stackoverflow.com/questions/39809084/injecting-ngcontrol-in-custom-validator-directive-causes-cyclic-dependency )

@khashayar
Copy link
Owner

@Russoturisto Can this issue be closed or do you still facing any problems?

@dankahle
Copy link

dankahle commented Feb 8, 2018

This is still an issue. Not sure why you closed it. If you look at his stackblitz examples, it's easy to see. I just got the latest material and still happening. For some reason, his injecting NgControl into the constructor does the trick. It's one of several material issues. Several components have their own ControlValueAccessor and you can only have one of those, input[matAutoComplete] is one, and the code crashes on that, messes up my app at least. I put your opt out class on it and all worked fine with the rest of my inputs, but I notice that ngModel.touched isn't happening, so this is still an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants