Changeset 58133
- Timestamp:
- 05/11/2024 06:26:06 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/lib/admin-bar.js
r57987 r58133 96 96 } 97 97 98 if ( skipLink ) {99 // Focus the target of skip link after pressing Enter.100 skipLink.addEventListener( 'keydown', focusTargetAfterEnter );101 }102 103 98 if ( shortlink ) { 104 99 shortlink.addEventListener( 'click', clickShortlink ); … … 171 166 } else { 172 167 addClass( wrapper, 'hover' ); 173 }174 }175 176 /**177 * Focus the target of skip link after pressing Enter.178 *179 * @since 5.3.1180 *181 * @param {Event} event The keydown event.182 */183 function focusTargetAfterEnter( event ) {184 var id, userAgent;185 186 if ( event.which !== 13 ) {187 return;188 }189 190 id = event.target.getAttribute( 'href' );191 userAgent = navigator.userAgent.toLowerCase();192 193 if ( userAgent.indexOf( 'applewebkit' ) > -1 && id && id.charAt( 0 ) === '#' ) {194 setTimeout( function() {195 var target = document.getElementById( id.replace( '#', '' ) );196 197 if ( target ) {198 target.setAttribute( 'tabIndex', '0' );199 target.focus();200 }201 }, 100 );202 168 } 203 169 }
Note: See TracChangeset
for help on using the changeset viewer.