Skip to:
Content

BuddyPress.org

Changeset 12649


Ignore:
Timestamp:
05/13/2020 04:58:32 PM (5 years ago)
Author:
imath
Message:

Hello BuddyPress Screen: a11y improvements

Make sure using the TAB key or the SHIFT + TAB keys when the Hello Screen is displayed focuses links inside it.

Props mercime

See #8270

File:
1 edited

Legend:

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

    r12458 r12649  
    2929
    3030        $( '#TB_ajaxContent' ).prop( 'style', 'height: 100%; width: auto; padding: 0; border: none;' );
     31
     32        var tabbables = $( ':tabbable', '#TB_ajaxContent' ), lastTabbable = tabbables.last();
     33
     34        // Move the focus to the Modal's close button once the last Hello link was tabbed out.
     35        $( '#TB_window' ).on( 'keydown', function( event ) {
     36            if ( 9 === event.keyCode && ! event.shiftKey && $( lastTabbable ).prop( 'classList' ).value === $( event.target ).prop( 'classList' ).value ) {
     37                event.preventDefault();
     38
     39                $( '#TB_closeWindowButton' ).focus();
     40            }
     41
     42            if ( 9 === event.keyCode && event.shiftKey && 'TB_closeWindowButton' === $( event.target ).prop( 'id' ) ) {
     43                event.preventDefault();
     44
     45                $( lastTabbable ).focus();
     46            }
     47        } );
    3148    };
    3249
Note: See TracChangeset for help on using the changeset viewer.