Skip to content

Commit 3600426

Browse files
ellatrixclaude
andcommitted
Expose the editable root host as a labelled textbox
While the writing flow wrapper is the editing host it takes focus, but carried no role or accessible name, so assistive technology announced an unlabelled editable region. Mark it as a multiline textbox named "Editor canvas" while it is the host, and remove the attributes when it stops. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent d7b21ad commit 3600426

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

packages/block-editor/src/components/writing-flow/use-editable-root.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* WordPress dependencies
33
*/
4+
import { __ } from '@wordpress/i18n';
45
import { useSelect } from '@wordpress/data';
56
import { useRefEffect } from '@wordpress/compose';
67
import { hasBlockSupport } from '@wordpress/blocks';
@@ -76,6 +77,13 @@ export default function useEditableRoot() {
7677
}
7778
}
7879

80+
// Expose the host as a named multiline textbox so it has a
81+
// role and accessible name once it takes focus. The label is
82+
// generic because the host can span several blocks.
83+
node.setAttribute( 'role', 'textbox' );
84+
node.setAttribute( 'aria-multiline', 'true' );
85+
node.setAttribute( 'aria-label', __( 'Editor canvas' ) );
86+
7987
// Move focus from the block's editable element to the
8088
// wrapper, but only when an editable element belonging to
8189
// the selected block has focus. Never steal focus from other
@@ -110,6 +118,9 @@ export default function useEditableRoot() {
110118
! isMultiSelecting()
111119
) {
112120
node.setAttribute( 'contenteditable', 'false' );
121+
node.removeAttribute( 'role' );
122+
node.removeAttribute( 'aria-multiline' );
123+
node.removeAttribute( 'aria-label' );
113124

114125
// If the wrapper held focus, return focus to the editable
115126
// element containing the selection, which is focusable again

0 commit comments

Comments
 (0)