WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
9.99k stars 4.02k forks source link

Block Bindings: Improve accessibility of bound paragraphs when using a screenreader in Navigation Mode #62933

Open artemiomorales opened 1 week ago

artemiomorales commented 1 week ago

Description

Actual: Currently, when tabbing to a bound paragraph in Navigation Mode, the NVDA screenreader announces the bound paragraph's original content, not its override content, which may be confusing and giver users incorrect information of what is displayed on the page.

Expected: The screenreader announces the override content, not the original content.

Step-by-step reproduction instructions

1. Register post meta by adding this snippet to your theme's functions.php ```php add_action( 'init', 'test_block_bindings' ); function test_block_bindings() { register_meta( 'post', 'text_field', array( 'show_in_rest' => true, 'single' => true, 'type' => 'string', 'default' => 'default text value', ) ); } ```
2. Add a paragraph block bound to the custom field using the Code Editor ```

Bound paragraph

```
  1. Override the paragraph content by typing into the bound paragraph.

  2. Using the NVDA screen reader, navigate to the bound paragraph in Navigation Mode, and see that the paragraph's original content, rather than its bound content, is announced.

Screenshots, screen recording, code snippet

(Pardon the background noise — I was unable to use my isolated microphone to capture the sound of the screenreader)

https://github.com/WordPress/gutenberg/assets/5360536/f8428579-3b69-4579-be3c-e5707363eb1c

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

afercia commented 1 week ago

This happens with all screen readers. Actually, the 'black box' is a button element. Screen readers announce the button aria-label which contains additional information about the block like:

Example of this button markup:

<button
    type="button"
    class="components-button block-selection-button_select-button"
    aria-label="Paragraph Block. Row 1. Bound paragraph"
>
        Paragraph
</button>

The actual block content, if any, is appended to the aria-label.

This is an accessibility feature that was added a while ago to give screen reader users more context about what the block content is.

The Bindings API behavior introduces a discrepancy between the content in the block markup (and post_content) and the visible actual content retrieved from the provided source.

This is a problem not only for screen readers but also for any other software or plugins that retrieve the post content and assume it is the 'real' content while. Thinking for example at plugins that run analysis of the post content Cc @enricobattocchi