Change event is not dispatched for particular keypress actions on currency mask.
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.
- If I change the value by pressing keys
0to9a change event gets dispatched. - If I change the value by pressing
k,m,ArrowUpandArrowDownNO change event gets dispatched.
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
applyInputValueis executed beforeblurEventapplyInputValuedoes set undoValue to the new valueblurEventdoes only dispatch a change event if undoValue is not equal to new value
Proposed fix
Remove inputmask.undoValue = inputmask._valueGet(true); and rely on blurEvent to update undoValue.
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.