From a39ae803b6eb708973b885c5b03836be2c5b89de Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Fri, 27 Mar 2015 22:53:50 +0000 Subject: [PATCH] Theme Switcher: Opening themes details modal shouldn't require two clicks on touch devices. Inspired by [26838]. see #31794. git-svn-id: https://develop.svn.wordpress.org/trunk@31914 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/customize-controls.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index a2b9489240..781a255173 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -1847,19 +1847,31 @@ */ api.ThemeControl = api.Control.extend({ + touchDrag: false, + /** * @since 4.2.0 */ ready: function() { var control = this; + control.container.on( 'touchmove', '.theme', function() { + control.touchDrag = true; + }); + // Bind details view trigger. - control.container.on( 'click keydown', '.theme', function( event ) { + control.container.on( 'click keydown touchend', '.theme', function( event ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - if ( 'button' === event.target.className ) { + // Bail if the user scrolled on a touch device. + if ( control.touchDrag === true ) { + return control.touchDrag = false; + } + + // Prevent the modal from showing when the user clicks the action button. + if ( $( event.target ).is( '.theme-actions .button' ) ) { return; }