Skip to content

Components: Placeholder instructions prop spoken message can be too regular and incorrectly take precedence over other spoken messages #64040

@talldan

Description

@talldan

Description

The Placeholder component's instructions prop triggers whenever the component mounts and the instructions are defined, and this can be a little bit too much, causing it to take precedence over other messages or be announced very unexpectedly:

useEffect( () => {
if ( instructions ) {
speak( instructions );
}
}, [ instructions ] );

For example, the message can be triggered when:

  • loading a post
  • switching between code and visual editor modes (in this case there's also supposed to be a spoken message about switching modes, but it gets clobbered by the placeholder because every time speak is called the current spoken messages are cleared)
  • A pattern containing those blocks is inserted

If you have multiple blocks in a post in placeholder state they can also all try speaking at once, which is very impolite.

Feels to me like this prop doesn't work in the right way. The instructions should probably only be read when the block is interacted with (selected?) and even then some care needs to be taken to ensure it only happens infrequently preferably on the first interaction. I'd question whether a spoken message is the right option at all as I think they're best for providing feedback about a current user action, but it'd be good to get further accessibility feedback on that.

Step-by-step reproduction instructions

  1. Insert a group block into a post and leave it in the placeholder state
  2. In the Editor options menu, switch to Code Editor mode
  3. Switch back to Visual editor mode

Note that the spoken message for switching back to Visual Editor mode is never announced and the assertive aria-live region is empty. The group block's instructions can be announced even though they're polite` and not currently being interacted with.

Screenshots, screen recording, code snippet

No response

Environment info

No response

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Accessibility FeedbackNeed input from accessibility[Feature] UI ComponentsImpacts or related to the UI component system[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions