Skip to:
Content

BuddyPress.org

Changeset 12101


Ignore:
Timestamp:
05/17/2018 10:52:01 PM (7 years ago)
Author:
djpaul
Message:

Admin, Welcome screen: revert the changes to the "esc" handler in r12095.

The change was causing the modal to only close if the modal had focus.

See #7835

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/js/hello.js

    r12095 r12101  
    5353     */
    5454    var bp_hello_close_modal = function() {
     55        var backdrop = document.getElementById( 'bp-hello-backdrop' ),
     56            modal = document.getElementById( 'bp-hello-container' );
     57
    5558        document.body.classList.remove( 'bp-disable-scroll' );
    5659
    57         // Hide modal and overlay.
    58         document.getElementById( 'bp-hello-container' ).style.display = 'none';
    59         document.getElementById( 'bp-hello-backdrop' ).style.display  = 'none';
     60        // Remove modal and overlay.
     61        modal.parentNode.removeChild( modal );
     62        backdrop.parentNode.removeChild( backdrop );
    6063    };
    6164
     
    7477
    7578        // Check for TAB key press.
    76         if ( event.keyCode === 9 ) {
    77             // When SHIFT+TAB on first tab stop, go to last tab stop in modal.
    78             if ( event.shiftKey && document.activeElement === first_tab_stop ) {
    79                 event.preventDefault();
    80                 last_tab_stop.focus();
     79        if ( event.keyCode !== 9 ) {
     80            return;
     81        }
    8182
    82             // When TAB reaches last tab stop, go to first tab stop in modal.
    83             } else if ( document.activeElement === last_tab_stop ) {
    84                 event.preventDefault();
    85                 first_tab_stop.focus();
     83        // When SHIFT+TAB on first tab stop, go to last tab stop in modal.
     84        if ( event.shiftKey && document.activeElement === first_tab_stop ) {
     85            event.preventDefault();
     86            last_tab_stop.focus();
     87
     88        // When TAB reaches last tab stop, go to first tab stop in modal.
     89        } else if ( document.activeElement === last_tab_stop ) {
     90            event.preventDefault();
     91            first_tab_stop.focus();
     92        }
     93    };
     94
     95    /**
     96     * Close modal if escape key is presssed.
     97     *
     98     * @param {Event} event - A keyboard focus event.
     99     */
     100    document.addEventListener( 'keyup', function( event ) {
     101        if ( event.keyCode === 27 ) {
     102            if ( ! document.getElementById( 'bp-hello-backdrop' ) || ! document.getElementById( 'bp-hello-container' ) ) {
     103                return;
    86104            }
    87105
    88         // Check for ESCAPE key press.
    89         } else if ( event.keyCode === 27 ) {
    90106            bp_hello_close_modal();
    91107        }
    92     };
     108    }, false );
    93109
    94110    // Init modal after the screen's loaded.
Note: See TracChangeset for help on using the changeset viewer.