From aebf6125d9e9ae84239141bf5dca2c694c256364 Mon Sep 17 00:00:00 2001 From: Jeff Ong Date: Tue, 3 Sep 2024 17:38:07 -0400 Subject: [PATCH] Use inert instead of aria-hidden. --- packages/block-library/src/accordion-group/view.js | 10 +--------- packages/block-library/src/accordion-item/index.php | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/block-library/src/accordion-group/view.js b/packages/block-library/src/accordion-group/view.js index c21a1d0e4cdcd3..cf1639710bdd33 100644 --- a/packages/block-library/src/accordion-group/view.js +++ b/packages/block-library/src/accordion-group/view.js @@ -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: { @@ -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; - } ); - }, }, } ); diff --git a/packages/block-library/src/accordion-item/index.php b/packages/block-library/src/accordion-item/index.php index dcbe9a801356a7..d54f4e79819e4a 100644 --- a/packages/block-library/src/accordion-item/index.php +++ b/packages/block-library/src/accordion-item/index.php @@ -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.