From 1d3b1bdbcc36d78d0170ebe79e709a0e9fa7e8ef Mon Sep 17 00:00:00 2001 From: Steve Ferguson Date: Fri, 30 Dec 2016 07:45:59 -0500 Subject: [PATCH] Fix for cursor left when all text selected --- src/mask.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mask.js b/src/mask.js index 1f738ab..beaa78e 100644 --- a/src/mask.js +++ b/src/mask.js @@ -570,13 +570,13 @@ angular.module('ui.mask', []) selectionLenOld = oldSelectionLength || 0, isSelected = getSelectionLength(this) > 0, wasSelected = selectionLenOld > 0, + isKeyLeftArrow = eventWhich === 37, // Case: Typing a character to overwrite a selection - isAddition = (val.length > valOld.length) || (selectionLenOld && val.length > valOld.length - selectionLenOld), + isAddition = !isKeyLeftArrow && ((val.length > valOld.length) || (selectionLenOld && val.length > valOld.length - selectionLenOld)), // Case: Delete and backspace behave identically on a selection isDeletion = (val.length < valOld.length) || (selectionLenOld && val.length === valOld.length - selectionLenOld), isSelection = (eventWhich >= 37 && eventWhich <= 40) && e.shiftKey, // Arrow key codes - isKeyLeftArrow = eventWhich === 37, // Necessary due to "input" event not providing a key code isKeyBackspace = eventWhich === 8 || (eventType !== 'keyup' && isDeletion && (caretPosDelta === -1)), isKeyDelete = eventWhich === 46 || (eventType !== 'keyup' && isDeletion && (caretPosDelta === 0) && !wasSelected),