Created
March 16, 2015 12:28
-
-
Save nutti/6a5eb05f741b65649c2f to your computer and use it in GitHub Desktop.
[Onsen UI] Fix bug: Focus on input (filled with text) pushes cursor out of bounds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Don't send a synthetic click to disabled inputs (issue #62) | |
case 'button': | |
case 'select': | |
+ if (target.disabled) { | |
+ return true; | |
+ } | |
+ break; | |
case 'textarea': | |
- if (target.disabled) { | |
- return true; | |
+ if (target.disabled || target.value.length) { | |
+ return true; | |
} | |
break; | |
@@ -273,6 +277,10 @@ FastClick.prototype.needsClick = function(target) { | |
return true; | |
} | |
+ if ((target.type === 'text') && target.value.length) { | |
+ return true; | |
+ } | |
+ | |
break; | |
case 'label': | |
case 'video': | |
@@ -293,7 +301,7 @@ FastClick.prototype.needsFocus = function(target) { | |
'use strict'; | |
switch (target.nodeName.toLowerCase()) { | |
case 'textarea': | |
- return true; | |
+ return !target.value.length; | |
case 'select': | |
return !deviceIsAndroid; | |
case 'input': | |
@@ -308,7 +316,7 @@ FastClick.prototype.needsFocus = function(target) { | |
} | |
// No point in attempting to focus disabled inputs | |
- return !target.disabled && !target.readOnly; | |
+ return !target.disabled && !target.readOnly && !target.value.length; | |
default: | |
return (/\bneedsfocus\b/).test(target.className); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment