anein / angular2-trim-directive

the directive trims whitespaces from the end of an input text value.
MIT License
46 stars 26 forks source link

Directive trims empty string value, marking the control as dirty #15

Closed catarinacepeda closed 6 years ago

catarinacepeda commented 6 years ago

When using trim="blur" along with Reactive Forms, if the user focuses on the input field and then unfocuses, without typing anything, your directive will cause the Control to be marked as dirty (which interferes with application logic that depends on the Control being pristine, such as cancel/discard changes confirmation).

I looked at the code and I think the problem is in the updateValue() function. I think that if the value of the field is empty (''), then the updateValue() function should simply return without setting the value.

catarinacepeda commented 6 years ago

@anein Thanks for fixing this! 💯 Are you planning to make a release with this fixed soon?

anein commented 6 years ago

@catarinacepeda Oh. Sorry for the delay. New release has been published. 2.1.5. 😉👍