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.
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 theupdateValue()
function should simply return without setting the value.