Make WordPress Core

Changeset 44358


Ignore:
Timestamp:
12/21/2018 09:35:48 PM (6 years ago)
Author:
laurelfulford
Message:

Twenty Nineteen: Make sure links are followed on touchend, not touchstart.

The theme's original navigation JavaScript was making it so all links on a site were immediately followed on touchstart when using a touch-enabled device. This update makes sure links are followed at touchend, to improve usability and menu behavior.

Already committed to the 5.0 branch in [44357].

Props anevins, panchen, kjellr.
Fixes #45510.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js

    r44149 r44358  
    220220                var url = event.target.getAttribute( 'href' ) ? event.target.getAttribute( 'href' ) : '';
    221221
    222                 // If there’s a link, go to it on touchend
    223                 if ( '#' !== url && '' !== url ) {
    224                     window.location = url;
    225 
    226222                // Open submenu if url is #
    227                 } else if ( '#' === url && event.target.nextSibling.matches('.submenu-expand') ) {
    228 
     223                if ( '#' === url && event.target.nextSibling.matches('.submenu-expand') ) {
    229224                    openSubMenu( event.target );
    230 
    231                 // Prevent default touch events
    232                 } else {
    233 
    234                     event.preventDefault();
    235225                }
    236226            }
Note: See TracChangeset for help on using the changeset viewer.