Skip to content

Instantly share code, notes, and snippets.

@nutti
Created March 16, 2015 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nutti/6a5eb05f741b65649c2f to your computer and use it in GitHub Desktop.
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
// 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