Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Announce block selection changes manually on windows #24299

Merged
merged 1 commit into from
Aug 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wondered whether I should announce something like label + ', button'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think label is good enough.

}
}, [] );

function onKeyDown( event ) {
Expand Down