Skip to content

Commit

Permalink
fix(tap): Remove 300ms delay when tapping select elements
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Apr 6, 2014
1 parent b1d9ab8 commit cf68654
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion js/ext/angular/test/service/ionicTap.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ describe('Ionic Tap', function() {
var targetEle = {
dispatchEvent: function(clickEvent) {
this.clickEvent = clickEvent;
}
},
tagName: 'LABEL'
};
var e = { clientX: 99, clientY: 88 };
ionic.tap.simulateClick(targetEle, e);
Expand Down
12 changes: 5 additions & 7 deletions js/utils/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@
// only climb up a max of 5 parents, anything more probably isn't beneficial
if(!ele) break;

if( ele.tagName === "INPUT" ||
ele.tagName === "A" ||
ele.tagName === "BUTTON" ||
ele.tagName === "LABEL" ||
ele.tagName === "TEXTAREA" ) {

if( ele.tagName.match(/a|input|button|label|textarea|select/i) ) {
return ionic.tap.simulateClick(ele, e);
}
ele = ele.parentElement;
Expand Down Expand Up @@ -73,9 +68,12 @@

ele.dispatchEvent(clickEvent);

if(ele.tagName === 'INPUT' || ele.tagName === 'TEXTAREA') {
if( ele.tagName.match(/input|textarea/i) ) {
ele.focus();
e.preventDefault();
} else if( ele.tagName == 'SELECT' ) {
// select simulateClick should not preventDefault or else no options dialog
ele.focus();
} else {
ionic.tap.blurActive();
}
Expand Down
1 change: 1 addition & 0 deletions test/html/input-select.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>Input: Select</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<link href="../../dist/css/ionic.css" rel="stylesheet">
<script src="../../dist/js/ionic.bundle.js"></script>
</head>
<body>

Expand Down

0 comments on commit cf68654

Please sign in to comment.