RobinHerbots/Inputmask

Callback `onUnMask` calls too many times when set `autoUnmask: true` and using with FomanticUI form!

KiddoV opened this issue · 2 comments

Describe the bug

I have encountered a weird behavior when using the FUI form with the Inputmask plugin. When I set {autoUnmask: true} in Inputmask, the {onUnMask: (mVal, umVal)} method is called every time I interact with the form, such as focusing on any fields or changing input values in any fields. I would expect it to be called only when I change the input in its own field.

I am not sure if this conflict is due to FUI or if the problem lies with Inputmask.

Additionally, when I set {removeMaskOnSubmit: true} without the {autoUnmask: true} option, the value is not unmasked after submission.

Add a link to a codepen, jsfiddle or other example page which shows the problem

Here is my JSFiddle:
https://jsfiddle.net/KiddoV/rLb0f6nh/60/

Additional notes

According to @lubber - Owner of FUI:

This line is causing it
https://github.com/fomantic/Fomantic-UI/blob/fb2d8fcbc3f4de690f6df6a75a76452a8bf7e1a2/src/definitions/behaviors/form.js#L376
It is called to check for the dirty state on each blur/click/keyup/down event in FUI.
However, just accessing .val() to get the fields content is somehow causing inputmask to trigger their unmask event. From the jquery docs for .val i cannot tell why this is happening as no event is triggered by jquery. I think this needs investigation in the inputmask project.