TwentyTwentyOne: Add aria-controls attributes to primary sub-menu.

On the Twenty Twenty-One theme, this changeset adds `aria-controls` attribute to sub-menu buttons and an `id` to the sub-menu wrapper for additional context on what is being expanded.

Props bschneidewind, audrasjb, anandraj346.
Fixes #62973.

Built from https://develop.svn.wordpress.org/trunk@59856


git-svn-id: http://core.svn.wordpress.org/trunk@59198 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb
2025-02-22 00:30:22 +00:00
parent 39c764d2f8
commit 3dad409c39
2 changed files with 14 additions and 1 deletions

View File

@@ -120,6 +120,19 @@ function twentytwentyoneExpandSubMenu( el ) { // jshint ignore:line
};
}
// Add aria-controls attributes to primary sub-menu.
var subMenus = document.querySelectorAll( '.primary-menu-container .sub-menu' );
subMenus.forEach( function( subMenu, index ) {
var parentLi = subMenu.closest( 'li.menu-item-has-children' );
subMenu.id = 'sub-menu-' + ( index + 1 );
if ( parentLi ) {
var parentLink = parentLi.querySelector( 'button' );
if ( parentLink ) {
parentLink.setAttribute( 'aria-controls', subMenu.id );
}
}
} );
/**
* Trap keyboard navigation in the menu modal.
* Adapted from Twenty Twenty.

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.8-alpha-59855';
$wp_version = '6.8-alpha-59856';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.