[Accessibility] Add ability for a screen reader to announce the current tab on a sing… (#50373)

Add ability for a screen reader to announce the current tab on a single product page.

Co-authored-by: amesplant <95257231+amesplant-dmv@users.noreply.github.com>
This commit is contained in:
Ames Plant 2024-08-07 10:26:27 -05:00 committed by GitHub
parent 94f6ec5ccc
commit 2d8bd64c54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Add ability for a screen reader to announce the current tab on a single product page.

View File

@ -31,9 +31,11 @@ jQuery( function( $ ) {
var $tabs_wrapper = $tab.closest( '.wc-tabs-wrapper, .woocommerce-tabs' ); var $tabs_wrapper = $tab.closest( '.wc-tabs-wrapper, .woocommerce-tabs' );
var $tabs = $tabs_wrapper.find( '.wc-tabs, ul.tabs' ); var $tabs = $tabs_wrapper.find( '.wc-tabs, ul.tabs' );
$tabs.find( 'li' ).attr( 'aria-selected', 'false' );
$tabs.find( 'li' ).removeClass( 'active' ); $tabs.find( 'li' ).removeClass( 'active' );
$tabs_wrapper.find( '.wc-tab, .panel:not(.panel .panel)' ).hide(); $tabs_wrapper.find( '.wc-tab, .panel:not(.panel .panel)' ).hide();
$tab.closest( 'li' ).attr( 'aria-selected', 'true' );
$tab.closest( 'li' ).addClass( 'active' ); $tab.closest( 'li' ).addClass( 'active' );
$tabs_wrapper.find( '#' + $tab.attr( 'href' ).split( '#' )[1] ).show(); $tabs_wrapper.find( '#' + $tab.attr( 'href' ).split( '#' )[1] ).show();
} ) } )