Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Update ngClick.js - find label inside parent element to correctly prevent second click from being busted #11577

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ngTouch/directive/ngClick.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
lastLabelClickCoordinates = null;
}
// remember label click coordinates to prevent click busting of trigger click event on input
if (event.target.tagName.toLowerCase() === 'label') {
if (event.target.tagName.toLowerCase() === 'label' || findUpLabel(event.target)) {
lastLabelClickCoordinates = [x, y];
}

Expand All @@ -161,6 +161,14 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
event.target && event.target.blur();
}

function findUpLabel(el) {
while (el.parentNode) {
el = el.parentNode;
if (el.tagName && el.tagName.toLowerCase() === 'label')
return el;
}
return null;
}

// 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.
Expand Down