Browse Source

fix #2640 Disable radixfocus on second click

Robin Herbots 3 years ago
parent
commit
2dd2220fec
10 changed files with 342 additions and 327 deletions
  1. 1 1
      bower.json
  2. 1 1
      composer.json
  3. 18 13
      dist/inputmask.js
  4. 2 2
      dist/inputmask.min.js
  5. 18 13
      dist/jquery.inputmask.js
  6. 2 2
      dist/jquery.inputmask.min.js
  7. 3 1
      lib/eventhandlers.js
  8. 1 0
      lib/inputmask.js
  9. 295 293
      lib/positioning.js
  10. 1 1
      package.json

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.8-beta.46",
+  "version": "5.0.8-beta.47",
   "main": [
 	  "./index.js",
     "./css/inputmask.css"

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "5.0.8-beta.46",
+  "version": "5.0.8-beta.47",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 18 - 13
dist/inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2022 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.8-beta.46
+ * Version: 5.0.8-beta.47
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -505,7 +505,9 @@
                         s.HandleNativePlaceholder)(i, e.originalPlaceholder);
                     },
                     clickEvent: function(e, t) {
-                        var i = this.inputmask, n = this;
+                        var i = this.inputmask;
+                        i.clicked++;
+                        var n = this;
                         if ((n.inputmask.shadowRoot || n.ownerDocument).activeElement === n) {
                             var r = a.determineNewCaretPosition.call(i, a.caret.call(i, n), t);
                             void 0 !== r && a.caret.call(i, n, r);
@@ -517,16 +519,18 @@
                         o.handleRemove.call(t, r, n.keys.Delete, l), (0, s.writeBuffer)(r, a.getBuffer.call(t), i.p, e, t.undoValue !== t._valueGet(!0));
                     },
                     blurEvent: function(e) {
-                        var t = this.inputmask, i = t.opts, n = (0, t.dependencyLib)(this), r = this;
-                        if (r.inputmask) {
-                            (0, s.HandleNativePlaceholder)(r, t.originalPlaceholder);
-                            var l = r.inputmask._valueGet(), c = a.getBuffer.call(t).slice();
-                            "" !== l && (i.clearMaskOnLostFocus && (-1 === a.getLastValidPosition.call(t) && l === a.getBufferTemplate.call(t).join("") ? c = [] : s.clearOptionalTail.call(t, c)), 
-                            !1 === o.isComplete.call(t, c) && (setTimeout((function() {
-                                n.trigger("incomplete");
-                            }), 0), i.clearIncomplete && (a.resetMaskSet.call(t), c = i.clearMaskOnLostFocus ? [] : a.getBufferTemplate.call(t).slice())), 
-                            (0, s.writeBuffer)(r, c, void 0, e)), t.undoValue !== t._valueGet(!0) && (t.undoValue = t._valueGet(!0), 
-                            n.trigger("change"));
+                        var t = this.inputmask, i = t.opts, n = t.dependencyLib;
+                        t.clicked = 0;
+                        var r = n(this), l = this;
+                        if (l.inputmask) {
+                            (0, s.HandleNativePlaceholder)(l, t.originalPlaceholder);
+                            var c = l.inputmask._valueGet(), u = a.getBuffer.call(t).slice();
+                            "" !== c && (i.clearMaskOnLostFocus && (-1 === a.getLastValidPosition.call(t) && c === a.getBufferTemplate.call(t).join("") ? u = [] : s.clearOptionalTail.call(t, u)), 
+                            !1 === o.isComplete.call(t, u) && (setTimeout((function() {
+                                r.trigger("incomplete");
+                            }), 0), i.clearIncomplete && (a.resetMaskSet.call(t), u = i.clearMaskOnLostFocus ? [] : a.getBufferTemplate.call(t).slice())), 
+                            (0, s.writeBuffer)(l, u, void 0, e)), t.undoValue !== t._valueGet(!0) && (t.undoValue = t._valueGet(!0), 
+                            r.trigger("change"));
                         }
                     },
                     mouseenterEvent: function() {
@@ -1639,7 +1643,7 @@
                         e && (t.alias = e)), this.opts = n.default.extend(!0, {}, this.defaults, t), this.noMasksCache = t && void 0 !== t.definitions, 
                         this.userOptions = t || {}, b(this.opts.alias, t, this.opts)), this.refreshValue = !1, 
                         this.undoValue = void 0, this.$el = void 0, this.skipInputEvent = !1, this.validationEvent = !1, 
-                        this.ignorable = !1, this.maxLength, this.mouseEnter = !1, this.originalPlaceholder = void 0, 
+                        this.ignorable = !1, this.maxLength, this.mouseEnter = !1, this.clicked = 0, this.originalPlaceholder = void 0, 
                         this.isComposing = !1;
                     }
                 }
@@ -2473,6 +2477,7 @@
                             break;
 
                           case "radixFocus":
+                            if (n.clicked > 1 && 0 == c.validPositions.length) break;
                             if (function(e) {
                                 if ("" !== u.radixPoint && 0 !== u.digits) {
                                     var t = c.validPositions;

File diff suppressed because it is too large
+ 2 - 2
dist/inputmask.min.js


+ 18 - 13
dist/jquery.inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2022 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.8-beta.46
+ * Version: 5.0.8-beta.47
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(require("jquery")); else if ("function" == typeof define && define.amd) define([ "jquery" ], t); else {
@@ -384,7 +384,9 @@
                         s.HandleNativePlaceholder)(i, e.originalPlaceholder);
                     },
                     clickEvent: function(e, t) {
-                        var i = this.inputmask, n = this;
+                        var i = this.inputmask;
+                        i.clicked++;
+                        var n = this;
                         if ((n.inputmask.shadowRoot || n.ownerDocument).activeElement === n) {
                             var r = a.determineNewCaretPosition.call(i, a.caret.call(i, n), t);
                             void 0 !== r && a.caret.call(i, n, r);
@@ -396,16 +398,18 @@
                         o.handleRemove.call(t, r, n.keys.Delete, l), (0, s.writeBuffer)(r, a.getBuffer.call(t), i.p, e, t.undoValue !== t._valueGet(!0));
                     },
                     blurEvent: function(e) {
-                        var t = this.inputmask, i = t.opts, n = (0, t.dependencyLib)(this), r = this;
-                        if (r.inputmask) {
-                            (0, s.HandleNativePlaceholder)(r, t.originalPlaceholder);
-                            var l = r.inputmask._valueGet(), c = a.getBuffer.call(t).slice();
-                            "" !== l && (i.clearMaskOnLostFocus && (-1 === a.getLastValidPosition.call(t) && l === a.getBufferTemplate.call(t).join("") ? c = [] : s.clearOptionalTail.call(t, c)), 
-                            !1 === o.isComplete.call(t, c) && (setTimeout((function() {
-                                n.trigger("incomplete");
-                            }), 0), i.clearIncomplete && (a.resetMaskSet.call(t), c = i.clearMaskOnLostFocus ? [] : a.getBufferTemplate.call(t).slice())), 
-                            (0, s.writeBuffer)(r, c, void 0, e)), t.undoValue !== t._valueGet(!0) && (t.undoValue = t._valueGet(!0), 
-                            n.trigger("change"));
+                        var t = this.inputmask, i = t.opts, n = t.dependencyLib;
+                        t.clicked = 0;
+                        var r = n(this), l = this;
+                        if (l.inputmask) {
+                            (0, s.HandleNativePlaceholder)(l, t.originalPlaceholder);
+                            var c = l.inputmask._valueGet(), u = a.getBuffer.call(t).slice();
+                            "" !== c && (i.clearMaskOnLostFocus && (-1 === a.getLastValidPosition.call(t) && c === a.getBufferTemplate.call(t).join("") ? u = [] : s.clearOptionalTail.call(t, u)), 
+                            !1 === o.isComplete.call(t, u) && (setTimeout((function() {
+                                r.trigger("incomplete");
+                            }), 0), i.clearIncomplete && (a.resetMaskSet.call(t), u = i.clearMaskOnLostFocus ? [] : a.getBufferTemplate.call(t).slice())), 
+                            (0, s.writeBuffer)(l, u, void 0, e)), t.undoValue !== t._valueGet(!0) && (t.undoValue = t._valueGet(!0), 
+                            r.trigger("change"));
                         }
                     },
                     mouseenterEvent: function() {
@@ -1518,7 +1522,7 @@
                         e && (t.alias = e)), this.opts = n.default.extend(!0, {}, this.defaults, t), this.noMasksCache = t && void 0 !== t.definitions, 
                         this.userOptions = t || {}, b(this.opts.alias, t, this.opts)), this.refreshValue = !1, 
                         this.undoValue = void 0, this.$el = void 0, this.skipInputEvent = !1, this.validationEvent = !1, 
-                        this.ignorable = !1, this.maxLength, this.mouseEnter = !1, this.originalPlaceholder = void 0, 
+                        this.ignorable = !1, this.maxLength, this.mouseEnter = !1, this.clicked = 0, this.originalPlaceholder = void 0, 
                         this.isComposing = !1;
                     }
                 }
@@ -2420,6 +2424,7 @@
                             break;
 
                           case "radixFocus":
+                            if (n.clicked > 1 && 0 == c.validPositions.length) break;
                             if (function(e) {
                                 if ("" !== u.radixPoint && 0 !== u.digits) {
                                     var t = c.validPositions;

File diff suppressed because it is too large
+ 2 - 2
dist/jquery.inputmask.min.js


+ 3 - 1
lib/eventhandlers.js

@@ -92,7 +92,7 @@ var EventHandlers = {
         }
 
         inputmask.ignorable = opts.ignorables.includes(c);
-        return  EventHandlers.keypressEvent.call(this, e, checkval, writeOut, strict, ndx);
+        return EventHandlers.keypressEvent.call(this, e, checkval, writeOut, strict, ndx);
     },
     keypressEvent: function (e, checkval, writeOut, strict, ndx) {
         const inputmask = this.inputmask || this, opts = inputmask.opts, $ = inputmask.dependencyLib,
@@ -400,6 +400,7 @@ var EventHandlers = {
     },
     clickEvent: function (e, tabbed) {
         const inputmask = this.inputmask;
+        inputmask.clicked++;
 
         var input = this;
         if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement === input) {
@@ -427,6 +428,7 @@ var EventHandlers = {
     },
     blurEvent: function (e) {
         const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
+        inputmask.clicked=0;
 
         var $input = $(this),
             input = this;

+ 1 - 0
lib/inputmask.js

@@ -60,6 +60,7 @@ function Inputmask(alias, options, internal) {
     this.ignorable = false;
     this.maxLength;
     this.mouseEnter = false;
+    this.clicked = 0;
     this.originalPlaceholder = undefined; //needed for FF
     this.isComposing = false; //keydowncode == 229  compositionevent fallback
 }

+ 295 - 293
lib/positioning.js

@@ -1,348 +1,350 @@
 import {
-	determineTestTemplate,
-	getMaskTemplate,
-	getPlaceholder,
-	getTest,
-	getTests,
-	getTestTemplate
+    determineTestTemplate,
+    getMaskTemplate,
+    getPlaceholder,
+    getTest,
+    getTests,
+    getTestTemplate
 } from "./validation-tests";
 import {checkAlternationMatch} from "./validation";
 
 export {
-	caret,
-	determineLastRequiredPosition,
-	determineNewCaretPosition,
-	getBuffer,
-	getBufferTemplate,
-	getLastValidPosition,
-	isMask,
-	resetMaskSet,
-	seekNext,
-	seekPrevious,
-	translatePosition
+    caret,
+    determineLastRequiredPosition,
+    determineNewCaretPosition,
+    getBuffer,
+    getBufferTemplate,
+    getLastValidPosition,
+    isMask,
+    resetMaskSet,
+    seekNext,
+    seekPrevious,
+    translatePosition
 };
 
 //tobe put on prototype?
 function caret(input, begin, end, notranslate, isDelete) {
-	const inputmask = this,
-		opts = this.opts;
-
-	var range;
-	if (begin !== undefined) {
-		if (Array.isArray(begin)) {
-			end = inputmask.isRTL ? begin[0] : begin[1];
-			begin = inputmask.isRTL ? begin[1] : begin[0];
-		}
-		if (begin.begin !== undefined) {
-			end = inputmask.isRTL ? begin.begin : begin.end;
-			begin = inputmask.isRTL ? begin.end : begin.begin;
-		}
-		if (typeof begin === "number") {
-			begin = notranslate ? begin : translatePosition.call(inputmask, begin);
-			end = notranslate ? end : translatePosition.call(inputmask, end);
-			end = (typeof end == "number") ? end : begin;
-			// if (!$(input).is(":visible")) {
-			// 	return;
-			// }
-
-			var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
-			input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0;
-			input.inputmask.caretPos = {begin: begin, end: end}; //track caret internally
-			if (opts.insertModeVisual && opts.insertMode === false && begin === end) {
-				if (!isDelete) {
-					end++; //set visualization for insert/overwrite mode
-				}
-			}
-			if (input === (input.inputmask.shadowRoot || input.ownerDocument).activeElement) {
-				if ("setSelectionRange" in input) {
-					input.setSelectionRange(begin, end);
-				} else if (window.getSelection) {
-					range = document.createRange();
-					if (input.firstChild === undefined || input.firstChild === null) {
-						var textNode = document.createTextNode("");
-						input.appendChild(textNode);
-					}
-					range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length);
-					range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length);
-					range.collapse(true);
-					var sel = window.getSelection();
-					sel.removeAllRanges();
-					sel.addRange(range);
-					//input.focus();
-				} else if (input.createTextRange) {
-					range = input.createTextRange();
-					range.collapse(true);
-					range.moveEnd("character", end);
-					range.moveStart("character", begin);
-					range.select();
-				}
-			}
-		}
-	} else {
-		if ("selectionStart" in input && "selectionEnd" in input) {
-			begin = input.selectionStart;
-			end = input.selectionEnd;
-		} else if (window.getSelection) {
-			range = window.getSelection().getRangeAt(0);
-			if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
-				begin = range.startOffset;
-				end = range.endOffset;
-			}
-		} else if (document.selection && document.selection.createRange) {
-			range = document.selection.createRange();
-			begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length);
-			end = begin + range.text.length;
-		}
-
-		// if (opts.insertModeVisual && opts.insertMode === false && begin === (end - 1)) end--; //correct caret for insert/overwrite mode
-
-		/*eslint-disable consistent-return */
-		return {
-			"begin": notranslate ? begin : translatePosition.call(inputmask, begin),
-			"end": notranslate ? end : translatePosition.call(inputmask, end)
-		};
-		/*eslint-enable consistent-return */
-	}
+    const inputmask = this,
+        opts = this.opts;
+
+    var range;
+    if (begin !== undefined) {
+        if (Array.isArray(begin)) {
+            end = inputmask.isRTL ? begin[0] : begin[1];
+            begin = inputmask.isRTL ? begin[1] : begin[0];
+        }
+        if (begin.begin !== undefined) {
+            end = inputmask.isRTL ? begin.begin : begin.end;
+            begin = inputmask.isRTL ? begin.end : begin.begin;
+        }
+        if (typeof begin === "number") {
+            begin = notranslate ? begin : translatePosition.call(inputmask, begin);
+            end = notranslate ? end : translatePosition.call(inputmask, end);
+            end = (typeof end == "number") ? end : begin;
+            // if (!$(input).is(":visible")) {
+            // 	return;
+            // }
+
+            var scrollCalc = parseInt(((input.ownerDocument.defaultView || window).getComputedStyle ? (input.ownerDocument.defaultView || window).getComputedStyle(input, null) : input.currentStyle).fontSize) * end;
+            input.scrollLeft = scrollCalc > input.scrollWidth ? scrollCalc : 0;
+            input.inputmask.caretPos = {begin: begin, end: end}; //track caret internally
+            if (opts.insertModeVisual && opts.insertMode === false && begin === end) {
+                if (!isDelete) {
+                    end++; //set visualization for insert/overwrite mode
+                }
+            }
+            if (input === (input.inputmask.shadowRoot || input.ownerDocument).activeElement) {
+                if ("setSelectionRange" in input) {
+                    input.setSelectionRange(begin, end);
+                } else if (window.getSelection) {
+                    range = document.createRange();
+                    if (input.firstChild === undefined || input.firstChild === null) {
+                        var textNode = document.createTextNode("");
+                        input.appendChild(textNode);
+                    }
+                    range.setStart(input.firstChild, begin < input.inputmask._valueGet().length ? begin : input.inputmask._valueGet().length);
+                    range.setEnd(input.firstChild, end < input.inputmask._valueGet().length ? end : input.inputmask._valueGet().length);
+                    range.collapse(true);
+                    var sel = window.getSelection();
+                    sel.removeAllRanges();
+                    sel.addRange(range);
+                    //input.focus();
+                } else if (input.createTextRange) {
+                    range = input.createTextRange();
+                    range.collapse(true);
+                    range.moveEnd("character", end);
+                    range.moveStart("character", begin);
+                    range.select();
+                }
+            }
+        }
+    } else {
+        if ("selectionStart" in input && "selectionEnd" in input) {
+            begin = input.selectionStart;
+            end = input.selectionEnd;
+        } else if (window.getSelection) {
+            range = window.getSelection().getRangeAt(0);
+            if (range.commonAncestorContainer.parentNode === input || range.commonAncestorContainer === input) {
+                begin = range.startOffset;
+                end = range.endOffset;
+            }
+        } else if (document.selection && document.selection.createRange) {
+            range = document.selection.createRange();
+            begin = 0 - range.duplicate().moveStart("character", -input.inputmask._valueGet().length);
+            end = begin + range.text.length;
+        }
+
+        // if (opts.insertModeVisual && opts.insertMode === false && begin === (end - 1)) end--; //correct caret for insert/overwrite mode
+
+        /*eslint-disable consistent-return */
+        return {
+            "begin": notranslate ? begin : translatePosition.call(inputmask, begin),
+            "end": notranslate ? end : translatePosition.call(inputmask, end)
+        };
+        /*eslint-enable consistent-return */
+    }
 }
 
 //tobe put on prototype?
 function determineLastRequiredPosition(returnDefinition) {
-	const inputmask = this,
-		maskset = this.maskset,
-		$ = this.dependencyLib;
-
-	var buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true, true),
-		bl = buffer.length,
-		pos, lvp = getLastValidPosition.call(inputmask),
-		positions = {},
-		lvTest = maskset.validPositions[lvp],
-		ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined,
-		testPos;
-	for (pos = lvp + 1; pos < buffer.length; pos++) {
-		testPos = getTestTemplate.call(inputmask, pos, ndxIntlzr, pos - 1);
-		ndxIntlzr = testPos.locator.slice();
-		positions[pos] = $.extend(true, {}, testPos);
-	}
-
-	var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
-	for (pos = bl - 1; pos > lvp; pos--) {
-		testPos = positions[pos];
-		if ((testPos.match.optionality ||
-				(testPos.match.optionalQuantifier && testPos.match.newBlockMarker) ||
-				(lvTestAlt &&
-					(
-						(lvTestAlt !== positions[pos].locator[lvTest.alternation] && testPos.match.static != true) ||
-						(testPos.match.static === true &&
-							testPos.locator[lvTest.alternation] &&
-							checkAlternationMatch.call(inputmask, testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) &&
-							getTests.call(inputmask, pos)[0].def !== "")
-					)
-				)) &&
-			buffer[pos] === getPlaceholder.call(inputmask, pos, testPos.match)) {
-			bl--;
-		} else {
-			break;
-		}
-	}
-	return returnDefinition ? {
-		"l": bl,
-		"def": positions[bl] ? positions[bl].match : undefined
-	} : bl;
+    const inputmask = this,
+        maskset = this.maskset,
+        $ = this.dependencyLib;
+
+    var buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true, true),
+        bl = buffer.length,
+        pos, lvp = getLastValidPosition.call(inputmask),
+        positions = {},
+        lvTest = maskset.validPositions[lvp],
+        ndxIntlzr = lvTest !== undefined ? lvTest.locator.slice() : undefined,
+        testPos;
+    for (pos = lvp + 1; pos < buffer.length; pos++) {
+        testPos = getTestTemplate.call(inputmask, pos, ndxIntlzr, pos - 1);
+        ndxIntlzr = testPos.locator.slice();
+        positions[pos] = $.extend(true, {}, testPos);
+    }
+
+    var lvTestAlt = lvTest && lvTest.alternation !== undefined ? lvTest.locator[lvTest.alternation] : undefined;
+    for (pos = bl - 1; pos > lvp; pos--) {
+        testPos = positions[pos];
+        if ((testPos.match.optionality ||
+                (testPos.match.optionalQuantifier && testPos.match.newBlockMarker) ||
+                (lvTestAlt &&
+                    (
+                        (lvTestAlt !== positions[pos].locator[lvTest.alternation] && testPos.match.static != true) ||
+                        (testPos.match.static === true &&
+                            testPos.locator[lvTest.alternation] &&
+                            checkAlternationMatch.call(inputmask, testPos.locator[lvTest.alternation].toString().split(","), lvTestAlt.toString().split(",")) &&
+                            getTests.call(inputmask, pos)[0].def !== "")
+                    )
+                )) &&
+            buffer[pos] === getPlaceholder.call(inputmask, pos, testPos.match)) {
+            bl--;
+        } else {
+            break;
+        }
+    }
+    return returnDefinition ? {
+        "l": bl,
+        "def": positions[bl] ? positions[bl].match : undefined
+    } : bl;
 }
 
 //tobe put on prototype?
 function determineNewCaretPosition(selectedCaret, tabbed, positionCaretOnClick) {
-	const inputmask = this,
-		maskset = this.maskset,
-		opts = this.opts;
-
-	function doRadixFocus(clickPos) {
-		if (opts.radixPoint !== "" && opts.digits !== 0) {
-			var vps = maskset.validPositions;
-			if (vps[clickPos] === undefined || (vps[clickPos].input === getPlaceholder.call(inputmask, clickPos))) {
-				if (clickPos < seekNext.call(inputmask, -1)) return true;
-				var radixPos = getBuffer.call(inputmask).indexOf(opts.radixPoint);
-				if (radixPos !== -1) {
-					for (let vp = 0, vpl = vps.length; vp < vpl; vp++) {
-						if (vps[vp] && radixPos < vp && vps[vp].input !== getPlaceholder.call(inputmask, vp)) {
-							return false;
-						}
-					}
-					return true;
-				}
-			}
-		}
-		return false;
-	}
-
-	if (tabbed) {
-		if (inputmask.isRTL) {
-			selectedCaret.end = selectedCaret.begin;
-		} else {
-			selectedCaret.begin = selectedCaret.end;
-		}
-	}
-	if (selectedCaret.begin === selectedCaret.end) {
-		positionCaretOnClick = positionCaretOnClick || opts.positionCaretOnClick;
-		switch (positionCaretOnClick) {
-			case "none":
-				break;
-			case "select":
-				selectedCaret = {begin: 0, end: getBuffer.call(inputmask).length};
-				break;
-			case "ignore":
-				selectedCaret.end = selectedCaret.begin = seekNext.call(inputmask, getLastValidPosition.call(inputmask));
-				break;
-			case "radixFocus":
-				if (doRadixFocus(selectedCaret.begin)) {
-					var radixPos = getBuffer.call(inputmask).join("").indexOf(opts.radixPoint);
-					selectedCaret.end = selectedCaret.begin = opts.numericInput ? seekNext.call(inputmask, radixPos) : radixPos;
-					break;
-				} //fallback to lvp
-			// eslint-disable-next-line no-fallthrough
-			default: //lvp:
-				var clickPosition = selectedCaret.begin,
-					lvclickPosition = getLastValidPosition.call(inputmask, clickPosition, true),
-					lastPosition = seekNext.call(inputmask, (lvclickPosition === -1 && !isMask.call(inputmask, 0)) ? -1 : lvclickPosition);
-
-				if (clickPosition <= lastPosition) {
-					selectedCaret.end = selectedCaret.begin = !isMask.call(inputmask, clickPosition, false, true) ? seekNext.call(inputmask, clickPosition) : clickPosition;
-				} else {
-					var lvp = maskset.validPositions[lvclickPosition],
-						tt = getTestTemplate.call(inputmask, lastPosition, lvp ? lvp.match.locator : undefined, lvp),
-						placeholder = getPlaceholder.call(inputmask, lastPosition, tt.match);
-					if ((placeholder !== "" && getBuffer.call(inputmask)[lastPosition] !== placeholder && tt.match.optionalQuantifier !== true && tt.match.newBlockMarker !== true) || (!isMask.call(inputmask, lastPosition, opts.keepStatic, true) && tt.match.def === placeholder)) {
-						var newPos = seekNext.call(inputmask, lastPosition);
-						if (clickPosition >= newPos || clickPosition === lastPosition) {
-							lastPosition = newPos;
-						}
-					}
-					selectedCaret.end = selectedCaret.begin = lastPosition;
-				}
-		}
-
-		return selectedCaret;
-	}
+    const inputmask = this,
+        maskset = this.maskset,
+        opts = this.opts;
+
+    function doRadixFocus(clickPos) {
+        if (opts.radixPoint !== "" && opts.digits !== 0) {
+            var vps = maskset.validPositions;
+            if (vps[clickPos] === undefined || (vps[clickPos].input === getPlaceholder.call(inputmask, clickPos))) {
+                if (clickPos < seekNext.call(inputmask, -1)) return true;
+                var radixPos = getBuffer.call(inputmask).indexOf(opts.radixPoint);
+                if (radixPos !== -1) {
+                    for (let vp = 0, vpl = vps.length; vp < vpl; vp++) {
+                        if (vps[vp] && radixPos < vp && vps[vp].input !== getPlaceholder.call(inputmask, vp)) {
+                            return false;
+                        }
+                    }
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    if (tabbed) {
+        if (inputmask.isRTL) {
+            selectedCaret.end = selectedCaret.begin;
+        } else {
+            selectedCaret.begin = selectedCaret.end;
+        }
+    }
+    if (selectedCaret.begin === selectedCaret.end) {
+        positionCaretOnClick = positionCaretOnClick || opts.positionCaretOnClick;
+        switch (positionCaretOnClick) {
+            case "none":
+                break;
+            case "select":
+                selectedCaret = {begin: 0, end: getBuffer.call(inputmask).length};
+                break;
+            case "ignore":
+                selectedCaret.end = selectedCaret.begin = seekNext.call(inputmask, getLastValidPosition.call(inputmask));
+                break;
+            case "radixFocus":
+                if (inputmask.clicked > 1 && maskset.validPositions.length == 0)
+                    break;
+                if (doRadixFocus(selectedCaret.begin)) {
+                    var radixPos = getBuffer.call(inputmask).join("").indexOf(opts.radixPoint);
+                    selectedCaret.end = selectedCaret.begin = opts.numericInput ? seekNext.call(inputmask, radixPos) : radixPos;
+                    break;
+                } //fallback to lvp
+            // eslint-disable-next-line no-fallthrough
+            default: //lvp:
+                var clickPosition = selectedCaret.begin,
+                    lvclickPosition = getLastValidPosition.call(inputmask, clickPosition, true),
+                    lastPosition = seekNext.call(inputmask, (lvclickPosition === -1 && !isMask.call(inputmask, 0)) ? -1 : lvclickPosition);
+
+                if (clickPosition <= lastPosition) {
+                    selectedCaret.end = selectedCaret.begin = !isMask.call(inputmask, clickPosition, false, true) ? seekNext.call(inputmask, clickPosition) : clickPosition;
+                } else {
+                    var lvp = maskset.validPositions[lvclickPosition],
+                        tt = getTestTemplate.call(inputmask, lastPosition, lvp ? lvp.match.locator : undefined, lvp),
+                        placeholder = getPlaceholder.call(inputmask, lastPosition, tt.match);
+                    if ((placeholder !== "" && getBuffer.call(inputmask)[lastPosition] !== placeholder && tt.match.optionalQuantifier !== true && tt.match.newBlockMarker !== true) || (!isMask.call(inputmask, lastPosition, opts.keepStatic, true) && tt.match.def === placeholder)) {
+                        var newPos = seekNext.call(inputmask, lastPosition);
+                        if (clickPosition >= newPos || clickPosition === lastPosition) {
+                            lastPosition = newPos;
+                        }
+                    }
+                    selectedCaret.end = selectedCaret.begin = lastPosition;
+                }
+        }
+
+        return selectedCaret;
+    }
 }
 
 
 //tobe put on prototype?
 function getBuffer(noCache) {
-	const inputmask = this, maskset = this.maskset;
+    const inputmask = this, maskset = this.maskset;
 
-	if (maskset.buffer === undefined || noCache === true) {
-		maskset.buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true);
-		if (maskset._buffer === undefined) maskset._buffer = maskset.buffer.slice();
-	}
-	return maskset.buffer;
+    if (maskset.buffer === undefined || noCache === true) {
+        maskset.buffer = getMaskTemplate.call(inputmask, true, getLastValidPosition.call(inputmask), true);
+        if (maskset._buffer === undefined) maskset._buffer = maskset.buffer.slice();
+    }
+    return maskset.buffer;
 }
 
 //tobe put on prototype?
 function getBufferTemplate() {
-	const inputmask = this, maskset = this.maskset;
-
-	if (maskset._buffer === undefined) {
-		//generate template
-		maskset._buffer = getMaskTemplate.call(inputmask, false, 1);
-		if (maskset.buffer === undefined) maskset.buffer = maskset._buffer.slice();
-	}
-	return maskset._buffer;
+    const inputmask = this, maskset = this.maskset;
+
+    if (maskset._buffer === undefined) {
+        //generate template
+        maskset._buffer = getMaskTemplate.call(inputmask, false, 1);
+        if (maskset.buffer === undefined) maskset.buffer = maskset._buffer.slice();
+    }
+    return maskset._buffer;
 }
 
 //tobe put on prototype?
 function getLastValidPosition(closestTo, strict, validPositions) {
-	const maskset = this.maskset;
-
-	var before = -1,
-		after = -1,
-		valids = validPositions || maskset.validPositions; //for use in valhook ~ context switch
-	if (closestTo === undefined) closestTo = -1;
-	for (var psNdx = 0, vpl = valids.length; psNdx < vpl; psNdx++) {
-		if (valids[psNdx] && (strict || valids[psNdx].generatedInput !== true)) {
-			if (psNdx <= closestTo) before = psNdx;
-			if (psNdx >= closestTo) after = psNdx;
-		}
-	}
-	return (before === -1 || before == closestTo) ? after : after == -1 ? before : (closestTo - before) < (after - closestTo) ? before : after;
+    const maskset = this.maskset;
+
+    var before = -1,
+        after = -1,
+        valids = validPositions || maskset.validPositions; //for use in valhook ~ context switch
+    if (closestTo === undefined) closestTo = -1;
+    for (var psNdx = 0, vpl = valids.length; psNdx < vpl; psNdx++) {
+        if (valids[psNdx] && (strict || valids[psNdx].generatedInput !== true)) {
+            if (psNdx <= closestTo) before = psNdx;
+            if (psNdx >= closestTo) after = psNdx;
+        }
+    }
+    return (before === -1 || before == closestTo) ? after : after == -1 ? before : (closestTo - before) < (after - closestTo) ? before : after;
 }
 
 //tobe put on prototype?
 function isMask(pos, strict, fuzzy) {
-	const inputmask = this, maskset = this.maskset;
-
-	var test = getTestTemplate.call(inputmask, pos).match;
-	if (test.def === "") test = getTest.call(inputmask, pos).match;
-
-	if (test.static !== true) {
-		return test.fn;
-	}
-	if (fuzzy === true && (maskset.validPositions[pos] !== undefined && maskset.validPositions[pos].generatedInput !== true)) {
-		return true;
-	}
-
-	if (strict !== true && pos > -1) {
-		if (fuzzy) { //check on the number of tests
-			var tests = getTests.call(inputmask, pos);
-			return tests.length > (1 + (tests[tests.length - 1].match.def === "" ? 1 : 0));
-		}
-		//else based on the template
-		var testTemplate = determineTestTemplate.call(inputmask, pos, getTests.call(inputmask, pos));
-		var testPlaceHolder = getPlaceholder.call(inputmask, pos, testTemplate.match);
-		return testTemplate.match.def !== testPlaceHolder;
-
-	}
-	return false;
+    const inputmask = this, maskset = this.maskset;
+
+    var test = getTestTemplate.call(inputmask, pos).match;
+    if (test.def === "") test = getTest.call(inputmask, pos).match;
+
+    if (test.static !== true) {
+        return test.fn;
+    }
+    if (fuzzy === true && (maskset.validPositions[pos] !== undefined && maskset.validPositions[pos].generatedInput !== true)) {
+        return true;
+    }
+
+    if (strict !== true && pos > -1) {
+        if (fuzzy) { //check on the number of tests
+            var tests = getTests.call(inputmask, pos);
+            return tests.length > (1 + (tests[tests.length - 1].match.def === "" ? 1 : 0));
+        }
+        //else based on the template
+        var testTemplate = determineTestTemplate.call(inputmask, pos, getTests.call(inputmask, pos));
+        var testPlaceHolder = getPlaceholder.call(inputmask, pos, testTemplate.match);
+        return testTemplate.match.def !== testPlaceHolder;
+
+    }
+    return false;
 }
 
 //tobe put on prototype?
 function resetMaskSet(soft) {
-	const maskset = this.maskset;
+    const maskset = this.maskset;
 
-	maskset.buffer = undefined;
-	if (soft !== true) {
-		maskset.validPositions = [];
-		maskset.p = 0;
-	}
+    maskset.buffer = undefined;
+    if (soft !== true) {
+        maskset.validPositions = [];
+        maskset.p = 0;
+    }
 }
 
 //tobe put on prototype?
 function seekNext(pos, newBlock, fuzzy) {
-	const inputmask = this;
-
-	if (fuzzy === undefined) fuzzy = true;
-	var position = pos + 1;
-	while (getTest.call(inputmask, position).match.def !== "" &&
-	((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
-		(newBlock !== true && !isMask.call(inputmask, position, undefined, fuzzy)))) {
-		position++;
-	}
-	return position;
+    const inputmask = this;
+
+    if (fuzzy === undefined) fuzzy = true;
+    var position = pos + 1;
+    while (getTest.call(inputmask, position).match.def !== "" &&
+    ((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
+        (newBlock !== true && !isMask.call(inputmask, position, undefined, fuzzy)))) {
+        position++;
+    }
+    return position;
 }
 
 //tobe put on prototype?
 function seekPrevious(pos, newBlock) {
-	const inputmask = this;
+    const inputmask = this;
 
-	var position = pos - 1;
-	if (pos <= 0) return 0;
+    var position = pos - 1;
+    if (pos <= 0) return 0;
 
-	while (position > 0 &&
-	((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
-		(newBlock !== true && !isMask.call(inputmask, position, undefined, true)))) {
-		position--;
-	}
-	return position;
+    while (position > 0 &&
+    ((newBlock === true && (getTest.call(inputmask, position).match.newBlockMarker !== true || !isMask.call(inputmask, position, undefined, true))) ||
+        (newBlock !== true && !isMask.call(inputmask, position, undefined, true)))) {
+        position--;
+    }
+    return position;
 }
 
 //tobe put on prototype?
 function translatePosition(pos) {
-	const inputmask = this,
-		opts = this.opts,
-		el = this.el;
-
-	if (inputmask.isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "") && el) {
-		pos = inputmask._valueGet().length - pos;
-		if (pos < 0) pos = 0;
-	}
-	return pos;
+    const inputmask = this,
+        opts = this.opts,
+        el = this.el;
+
+    if (inputmask.isRTL && typeof pos === "number" && (!opts.greedy || opts.placeholder !== "") && el) {
+        pos = inputmask._valueGet().length - pos;
+        if (pos < 0) pos = 0;
+    }
+    return pos;
 }

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.8-beta.46",
+  "version": "5.0.8-beta.47",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "dist/inputmask.js",
   "files": [