Changeset 58449
- Timestamp:
- 06/20/2024 07:39:50 PM (6 months ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/admin/common.js
r58375 r58449 904 904 905 905 /** 906 * Handles the `aria-haspopup` attribute on the current menu item when it has a submenu.907 *908 * @since 4.4.0909 *910 * @return {void}911 */912 function currentMenuItemHasPopup() {913 var $current = $( 'a.wp-has-current-submenu' );914 915 if ( 'folded' === menuState ) {916 // When folded or auto-folded and not responsive view, the current menu item does have a fly-out sub-menu.917 $current.attr( 'aria-haspopup', 'true' );918 } else {919 // When expanded or in responsive view, reset aria-haspopup.920 $current.attr( 'aria-haspopup', 'false' );921 }922 }923 924 $document.on( 'wp-menu-state-set wp-collapse-menu wp-responsive-activate wp-responsive-deactivate', currentMenuItemHasPopup );925 926 /**927 906 * Ensures an admin submenu is within the visual viewport. 928 907 * … … 1696 1675 $document.on( 'wp-responsive-activate.wp-responsive', function() { 1697 1676 self.activate(); 1677 self.toggleAriaHasPopup( 'add' ); 1698 1678 }).on( 'wp-responsive-deactivate.wp-responsive', function() { 1699 1679 self.deactivate(); 1680 self.toggleAriaHasPopup( 'remove' ); 1700 1681 }); 1701 1682 … … 1749 1730 var focusIsInToggle = $.contains( toggleButton, focusedElement ); 1750 1731 var focusIsInSidebar = $.contains( sidebar, focusedElement ); 1751 1732 1752 1733 if ( ! focusIsInToggle && ! focusIsInSidebar ) { 1753 1734 $( toggleButton ).trigger( 'click.wp-responsive' ); … … 1763 1744 return; 1764 1745 } 1765 1746 let state = ( 'false' === $( this ).attr( 'aria-expanded' ) ) ? 'true' : 'false'; 1766 1747 $( this ).parent( 'li' ).toggleClass( 'selected' ); 1748 $( this ).attr( 'aria-expanded', state ); 1767 1749 $( this ).trigger( 'focus' ); 1768 1750 event.preventDefault(); … … 1836 1818 1837 1819 this.maybeDisableSortables(); 1820 }, 1821 1822 /** 1823 * Toggles the aria-haspopup attribute for the responsive admin menu. 1824 * 1825 * The aria-haspopup attribute is only necessary for the responsive menu. 1826 * See ticket https://core.trac.wordpress.org/ticket/43095 1827 * 1828 * @since 6.6.0 1829 * 1830 * @param {string} action Whether to add or remove the aria-haspopup attribute. 1831 * 1832 * @return {void} 1833 */ 1834 toggleAriaHasPopup: function( action ) { 1835 var elements = $adminmenu.find( '[data-ariahaspopup]' ); 1836 1837 if ( action === 'add' ) { 1838 elements.each( function() { 1839 $( this ).attr( 'aria-haspopup', 'menu' ).attr( 'aria-expanded', 'false' ); 1840 } ); 1841 1842 return; 1843 } 1844 1845 elements.each( function() { 1846 $( this ).removeAttr( 'aria-haspopup' ).removeAttr( 'aria-expanded' ); 1847 } ); 1838 1848 }, 1839 1849 … … 2035 2045 setPinMenu(); 2036 2046 setMenuState(); 2037 currentMenuItemHasPopup();2038 2047 makeNoticesDismissible(); 2039 2048 aria_button_if_js(); -
trunk/src/wp-admin/menu-header.php
r56175 r58449 99 99 $class[] = 'wp-not-current-submenu'; 100 100 if ( ! empty( $submenu_items ) ) { 101 $aria_attributes .= ' aria-haspopup="true"';101 $aria_attributes .= 'data-ariahaspopup'; 102 102 } 103 103 }
Note: See TracChangeset
for help on using the changeset viewer.