RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.36k stars 2.18k forks source link

Change event is not dispatched for particular keypress actions on currency mask. #2757

Open niklaushug opened 7 months ago

niklaushug commented 7 months ago

Bug

Some keyboard interactions on a field with a currency mask does not dispatch a change event. Hence new values are only reflected inside the field but cannot be sended to a backend.

At least for keyboard interactions k, m, ArrowUp and ArrowDown a change event should be triggered somewhen.

You can see this behaviour on https://replit.com/@niklaushug/inputmask-does-not-dispatch-change-event-on-certain-keypress

Version 5.0.9-beta.39, 5.0.8 and more are affected by this error. I have no evidence that type of browser or operating system is relevant.

Reason

Proposed fix

Remove inputmask.undoValue = inputmask._valueGet(true); and rely on blurEvent to update undoValue.

See Pull Request 2758

Further thoughts

We may need a change event directly after keyboard interactions k, m, ArrowUp and ArrowDown, to ensure that the new value is saved even if the browser is closed before unfocus the field.