Closed zymr-keshav closed 5 years ago
Hey!
Yep. Weird behavior. I think it's safe to assume that the issue lies on line 129, causing the model isn't updated.
yes, the issue possibly on line number 129 and how to fix that? I have tried to create pull request but failed and also git clone but it failed due to typescript version mismatch.
this code changes fixed my issue but do not know whether it is applicable to all or not. One thing i did not understand is when we assign const previousValue = this._value;
then how these const trimmedValue = this._value.trim();
and previous.trim()
can be different?
private updateValue(event: string, value: string): void {
const currentValue = this.trim !== '' && event !== this.trim ? value : value.trim();
const previousValue = this._value;
let trimmedPreviousValue = '';
if (Boolean(previousValue)) {
trimmedPreviousValue = previousValue.toString()trim();
}
this.writeValue(currentValue);
const trimmedValue = this._value.trim();
if (trimmedValue !== previousValue && (trimmedValue !== '' || trimmedPreviousValue !== '')) {
this.onChange(this._value);
}
}
Pasting is also broken again :(
THAT condition, which is responsible for updating the model, wasn't optimized. Done and done. =)
//cc @alexvisenze @zymr-keshav
angular v 6.1.10 ng2-trim-directive v 2.3.0
using in reactive form with trim="blur" options it works fine as expected
BUT facing one strange issue. when user input only a single letter, it throws the same error as required.
interestingly it works fine when writing 2 letters and removes the later from the input box.
Will you please check this issue?
check this demo . enter 'a' and then enter
aa
and remove thea
why both are behaving differently?