From 7c031509a7b9a4d1355c61fc597100b3f91d11f6 Mon Sep 17 00:00:00 2001 From: mobilabgit Date: Tue, 14 Apr 2015 10:36:51 +0200 Subject: [PATCH] Update ngClick.js In our code we have an input element inside a label. The click on the label generates two clicks, but the second click was not recognised by angular-touch as a label click, because it only looks at the current element, instead of looking for a label in parent elements. Therefore, the second click gets busted, and clicking on the label doesn't do anything for 2500ms. I added the additional lookup for a containing label inside one of the conditions inside the onClick method. Closes #11577 --- src/ngTouch/directive/ngClick.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ngTouch/directive/ngClick.js b/src/ngTouch/directive/ngClick.js index f352c252f443..f37c72b28286 100644 --- a/src/ngTouch/directive/ngClick.js +++ b/src/ngTouch/directive/ngClick.js @@ -144,7 +144,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement', lastLabelClickCoordinates = null; } // remember label click coordinates to prevent click busting of trigger click event on input - if (nodeName_(event.target) === 'label') { + if (findUpLabel(event.target)) { lastLabelClickCoordinates = [x, y]; } @@ -163,6 +163,12 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement', event.target && event.target.blur && event.target.blur(); } + function findUpLabel(el) { + while (el) { + if (nodeName_(el) === 'label') return true; + el = el.parentNode; + } + } // Global touchstart handler that creates an allowable region for a click event. // This allowable region can be removed by preventGhostClick if we want to bust it.