RobinHerbots / Inputmask

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

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

Open KiddoV opened 1 month ago

KiddoV commented 1 month ago

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.

RobinHerbots commented 2 weeks ago

@KiddoV ,

Everytime the library request the value it will trigger the unmasking, when using the autoUnmask: true. This is logical ans I can not change that behavior from my end.

But what is too many? Do you get an error or so?

KiddoV commented 2 weeks ago

@RobinHerbots There's no error or anything, it's just the onUnMask get call too many time. Not sure if that is OK if I just leave it like that in my app?