From 86b90c1de4bcad1409b2f4010df9dd3838adc083 Mon Sep 17 00:00:00 2001 From: Rupesh Dabbir Date: Thu, 31 Aug 2017 23:23:15 -0700 Subject: [PATCH] dev: fix: Any occurance of Mask will push the cursor to one position back (AKA Reverse) Issue: - Any occurance of Mask anywhere, the cursor will go one position to the back! Fix Description: - Basically this fix will make sure the cursor is at the end position of the val. --- src/jquery.mask.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/jquery.mask.js b/src/jquery.mask.js index d60966fc..fa6fd54b 100755 --- a/src/jquery.mask.js +++ b/src/jquery.mask.js @@ -256,15 +256,14 @@ var keyCode = el.data('mask-keycode'); if ($.inArray(keyCode, jMask.byPassKeys) === -1) { - var newVal = p.getMasked(), - caretPos = p.getCaret(); + var newVal = p.getMasked(); setTimeout(function() { p.setCaret(p.calculateCaretPosition()); }, 10); p.val(newVal); - p.setCaret(caretPos); + p.setCaret(newVal.length); //For cut/paste, you will return val+mask length return p.callbacks(e); } }, @@ -455,9 +454,8 @@ p.destroyEvents(); p.events(); - var caret = p.getCaret(); p.val(p.getMasked()); - p.setCaret(caret); + p.setCaret(p.getMasked().length); } };