From f736ae510e8542e0078e3c1dd7b85291f0ec126d Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sun, 16 Feb 2014 22:07:19 -0600 Subject: [PATCH] blur active input w/ setTimeout --- js/utils/poly.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/js/utils/poly.js b/js/utils/poly.js index 97471d61e0e..975a83da736 100644 --- a/js/utils/poly.js +++ b/js/utils/poly.js @@ -47,8 +47,9 @@ if(ele.tagName === 'INPUT' || ele.tagName === 'TEXTAREA' || ele.tagName === 'SELECT') { ele.focus(); + e.preventDefault(); } else { - ele.blur(); + blurActive(); } // remember the coordinates of this tap so if it happens again we can ignore it @@ -103,12 +104,7 @@ // they didn't tap one of the above elements // if the currently active element is an input, and they tapped outside // of the current input, then unset its focus (blur) so the keyboard goes away - ele = document.activeElement; - if(ele && (ele.tagName === "INPUT" || - ele.tagName === "TEXTAREA" || - ele.tagName === "SELECT")) { - ele.blur(); - } + blurActive(); } function preventGhostClick(e) { @@ -159,6 +155,18 @@ return false; } + function blurActive() { + var ele = document.activeElement; + if(ele && (ele.tagName === "INPUT" || + ele.tagName === "TEXTAREA" || + ele.tagName === "SELECT")) { + // using a timeout to prevent funky scrolling while a keyboard hides + setTimeout(function(){ + ele.blur(); + }, 400); + } + } + function isRecentTap(event) { // loop through the tap coordinates and see if the same area has been tapped recently var tapId, existingCoordinates, currentCoordinates,