payform
payform copied to clipboard
Input event is prevented on auto-formatting
Hello!
Thank you for this great module!
However, when using auto-formatter and entering the numbers into input field, some events are prevented. This happens right before space character is automatically inserted, e.g. when entering 5213 2…:
- 5, got events
- 2, got events
- 1, got events
- 3, space is inserted, events are not fired
- 2, got events …
This makes data-binding to fail, because we can't know when value is changed (I'm integrating it with custom Angular 2+ component).
What could be done about this?
Thanks!
I've managed to work around this issue using the following approach:
inputElement.addEventListener('keydown', () => {
setTimeout(() => this.propagateValue(inputElement.value), 10);
});
The keydown event is fired every time, so we could rely on it. But the value is not yet updated when it's fired, so we need to wait for some time until it does.
This is kinda ugly, but works.
I would rather listen for input event, which is sealed by the library.
Might be related to #13
Thanks for the report.
Would not this be resolved by removing this line https://github.com/jondavidjohn/payform/blob/master/src/payform.coffee#L295 or by emitting a new input event at this point? Not sure what issues could this bring