Skip to content

Commit

Permalink
Announce block selection changes manually on windows (#24299)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Aug 3, 2020
1 parent 0330fa8 commit 2991fd7
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,22 @@ import {
getBlockType,
__experimentalGetAccessibleBlockLabel as getAccessibleBlockLabel,
} from '@wordpress/blocks';
import { speak } from '@wordpress/a11y';

/**
* Internal dependencies
*/
import BlockTitle from '../block-title';

/**
* Returns true if the user is using windows.
*
* @return {boolean} Whether the user is using Windows.
*/
function isWindows() {
return window.navigator.platform.indexOf( 'Win' ) > -1;
}

/**
* Block selection button component, displaying the label of the block. If the block
* descends from a root block, a button is displayed enabling the user to select
Expand Down Expand Up @@ -63,6 +73,13 @@ function BlockSelectionButton( { clientId, rootClientId, ...props } ) {
// Focus the breadcrumb in navigation mode.
useEffect( () => {
ref.current.focus();

// NVDA on windows suffers from a bug where focus changes are not announced properly
// See WordPress/gutenberg#24121 and nvaccess/nvda#5825 for more details
// To solve it we announce the focus change manually.
if ( isWindows() ) {
speak( label );
}
}, [] );

function onKeyDown( event ) {
Expand Down

0 comments on commit 2991fd7

Please sign in to comment.