Skip to content

Commit

Permalink
Use inert instead of aria-hidden.
Browse files Browse the repository at this point in the history
  • Loading branch information
jffng committed Sep 16, 2024
1 parent 5967cf1 commit db03ba8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
10 changes: 1 addition & 9 deletions packages/block-library/src/accordion-group/view.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { store, getContext, getElement } from '@wordpress/interactivity';
import { store, getContext } from '@wordpress/interactivity';

const { state } = store( 'core/accordion', {
state: {
Expand Down Expand Up @@ -34,13 +34,5 @@ const { state } = store( 'core/accordion', {
context.isOpen.push( id );
}
},
setTabIndex: () => {
const { ref } = getElement();
ref.querySelectorAll(
'button, a, input, textarea, select, summary, iframe'
).forEach( ( el ) => {
el.tabIndex = state.isOpen ? 0 : -1;
} );
},
},
} );
2 changes: 1 addition & 1 deletion packages/block-library/src/accordion-item/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function block_core_accordion_item_render( $attributes, $content ) {
if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-content' ) ) ) {
$p->set_attribute( 'id', $unique_id . '-content' );
$p->set_attribute( 'aria-labelledby', $unique_id );
$p->set_attribute( 'data-wp-bind--aria-hidden', '!state.isOpen' );
$p->set_attribute( 'data-wp-bind--inert', '!state.isOpen' );
$p->set_attribute( 'data-wp-watch', 'callbacks.setTabIndex' );

// Only modify content if all directives have been set.
Expand Down

0 comments on commit db03ba8

Please sign in to comment.