-
-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vue - Element value was changed outside of mask. #249
Comments
Can you please describe how the value can be changed outside? |
Refer to "How To Use: 2" on this fiddle https://jsfiddle.net/g0ld3neag1e/ev8k0goy/ This fiddle has my fix applied to it |
@g0ld3neag1e I played around with this fiddle and randomly typing numbers are breaking the Vue value in your fixed fiddle, too. (Tested on macos Latest chrome) |
@sem4phor Yes, the above 'fix,' fixes only a value changed outside of input. Such has an ajax call, or a document.getElement...value = ''; I just reused the same fiddle for both issues. Please refer to only # 2 for this particular issue. |
As far as i can see syncing the mask in every directive update hook has no negative impact. (No extra events are fired all values are in sync) So maybe this could be a solution @uNmAnNeR what do you think?
|
@sem4phor The same thing. Seems |
@sem4phor @g0ld3neag1e hello guys! sorry for long delay. changed function initMask(el, opts) {
el.addEventListener('input', e => {
console.log(e);
if (e.isTrusted) {
e.stopPropagation();
el.maskRef._onInput();
}
}, true);
el.maskRef = new IMask(el, opts).on('accept', function () {
el.maskRef._unbindEvents();
fireEvent(el, 'input');
el.maskRef._bindEvents();
fireEvent(el, 'accept', el.maskRef);
}).on('complete', function () {
fireEvent(el, 'complete', el.maskRef);
});
} Seem it's working, and probably it could be done a little bit better: https://github.com/probil/v-mask/blob/master/src/directive.js But still smells like hack. And also one big disadvantage, that directive can work only with masked values, so there is no way to bind model to |
found vuejs/vue#3666 |
An elements value can easily change outside the mask while using Vue.
I suggest changing the
update
function in the vue directive from:to:
This will prevent the user from having to call
updateValue()
from outside the mask themselves.The text was updated successfully, but these errors were encountered: