WordPress.org

Make WordPress Core

Changeset 44357


Ignore:
Timestamp:
12/21/2018 09:08:56 PM (7 months 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.

Props anevins, panchen, kjellr.
Fixes #45510.

File:
1 edited

Legend:

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

    r43904 r44357  
    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.