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

Input event is prevented on auto-formatting #28

Open
slavafomin opened this issue Sep 27, 2017 · 3 comments
Open

Input event is prevented on auto-formatting #28

slavafomin opened this issue Sep 27, 2017 · 3 comments

Comments

@slavafomin
Copy link

slavafomin commented Sep 27, 2017

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!

@slavafomin slavafomin changed the title Input event is prevented when space is inserted Input event is prevented on auto-formatting Sep 27, 2017
@slavafomin
Copy link
Author

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.

@jondavidjohn
Copy link
Owner

Might be related to #13

Thanks for the report.

@eduarguz
Copy link

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

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

No branches or pull requests

3 participants