Make WordPress Core

Ticket #48916: 48916.diff

File 48916.diff, 911 bytes (added by ianbelanger, 5 years ago)

Updated patch that adds modal check

  • src/wp-content/themes/twentytwenty/assets/js/index.js

     
    137137                        var target = event.target;
    138138                        var modal = document.querySelector( '.cover-modal.active' );
    139139
     140                        // if target onclick is <a> with # within the href attribute
     141                        if ( event.target.tagName.toLowerCase() === 'a' && event.target.hash.includes( '#' ) && modal !== null ) {
     142                                // untoggle the modal
     143                                this.untoggleModal( modal );
     144                                // wait 550 and scroll to the anchor
     145                                setTimeout( function() {
     146                                        var anchor = document.getElementById( event.target.hash.slice( 1 ) );
     147                                        anchor.scrollIntoView();
     148                                }, 550 );
     149                        }
     150
    140151                        if ( target === modal ) {
    141152                                this.untoggleModal( target );
    142153                        }