Skip to content

Commit 8498c6f

Browse files
committed
Comments: Remove touchstart event listeners from comment reply/cancel links.
The `touchstart` event on comment reply and cancel links fired before the browser could distinguish a tap from a scroll gesture, causing the reply form to open unexpectedly during scrolling. Since touchscreen users tapping a link already generate a `click` event, the `touchstart` listeners are unnecessary. Prior to ~2015 a `touchstart` event may have been useful to eliminate a 300ms delay for event handlers on tap, but this is long obsolete. Developed in WordPress#12168. Follow-up to r42360. Props edent, szandman, SergeyBiryukov, westonruter, afercia, peterwilsoncc, janpaulkleijn, madhazelnut, joostdevalk, pbearne, eherman24, Znuff. See #47510, #31590. Fixes #46713. git-svn-id: https://develop.svn.wordpress.org/trunk@62511 602fd350-edb4-49c9-b593-d223f7449a82
1 parent f1b6780 commit 8498c6f

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/js/_enqueues/lib/comment-reply.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ window.addComment = ( function( window ) {
9393
return;
9494
}
9595

96-
cancelElement.addEventListener( 'touchstart', cancelEvent );
97-
cancelElement.addEventListener( 'click', cancelEvent );
96+
cancelElement.addEventListener( 'click', cancelEvent );
9897

9998
// Submit the comment form when the user types [Ctrl] or [Cmd] + [Enter].
10099
var submitFormHandler = function( e ) {
@@ -117,8 +116,7 @@ window.addComment = ( function( window ) {
117116
for ( var i = 0, l = links.length; i < l; i++ ) {
118117
element = links[i];
119118

120-
element.addEventListener( 'touchstart', clickEvent );
121-
element.addEventListener( 'click', clickEvent );
119+
element.addEventListener( 'click', clickEvent );
122120
}
123121
}
124122

0 commit comments

Comments
 (0)