Mouse click to leave autonumeric field sometime could not fire jquery change event
See original GitHub issueCurrent behavior
After editing value on an autoNumeric field, if using mouse to click on other place, sometimes it could not fire the jquery change event of the input field, I can repeat the same problem in about 1 out of 20 times.
However, it is ok to fire the jquery change event if using keyboard TAB key to leave the field.
I have tried using jQuery v3.2.1 and the latest v3.3.1, the same problem exists.
Expected behavior
jquery change event is expected to be fired after changing value on an autoNumeric field then leaving the field by clicking other place
Steps to reproduce the problem
- Use autoNumeric version
<4.2.15>
- In the browser
<Firefox>
version<60.0.2>
, and<Chrome>
version<67.0.3396.87>
- On the
<Windows 10>
operating system - Then instantiate the autoNumeric object with the following options: new AutoNumeric(domElement, { options });
- As in live example below
Link to live example (ie. Codepen)
https://codepen.io/mars2018/pen/xzYXJV
In the example. let’s input value 1 and value 2 first, then start testing by changing the value 1, it will calculate value 3 when value 1 is changed.
After editing the value 1, if I use mouse to click the value 2 field (or other places), sometimes it could not fire the jquery change event so the value 3 is unchanged. Please note that it is not happened very time, it happens in about 1 out of 20 times.
While using keyborad TAB to move focus to “value 2 field” after changing “value 1 field”, it is always ok.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
Hi Alexandre, i updated my autonumerics.js to the last version and the error was gone. I thought i had the last version.
Thanks for your response.
Well, I changed the code to ditch jQuery and so far it works perfectly as intended (see the updated codepen).
I feel like I’m repeating myself, but jQuery events are bugged and cannot be relied on correctly. This is not the first time it happens, and anyway you might not need jQuery 😃
For the time being I’ll close that issue. Feel free to reopen it if you think this might also affect users that do not use jQuery.