Skip to content

Improve the labeling of EntitiesSavedStates when used with modal behavior #67354

@afercia

Description

@afercia

Description

Discovered while working on #67313 / #67351

When it is used with a modal behavior attached, the EntitiesSavedStates component has a role=dialog' and it's labelled via an aria-labelledby` attribute that points to these part:

<div
className="entities-saved-states__text-prompt--header-wrapper"
id={ renderDialog ? dialogLabel : undefined }
>
<strong className="entities-saved-states__text-prompt--header">
{ __( 'Are you ready to save?' ) }
</strong>
{ additionalPrompt }
</div>

The problem with that, is that when additionalPrompt is passed, it makes part of the dialog labeling which:

  • Makes the dialog labeling potentially too long and misleading.
  • The additionalPrompt text is meant to be more an additional description rather than a label.

For example. in the Theme preview in the Site editor the label of the dialog is as follows:

Are you ready to save? Saving your changes will change your active theme from Twenty Twenty-Five to Twenty Twenty-Four."

That's used for the label and it's way too long. The second part should be used for the description and the labeling should only be the first part: Are you ready to save?.

Image

Step-by-step reproduction instructions

First, apply the changes from #67351 if it's hasn't been merged yet as that PR fixes the labeling of the dialog.

  • Go to the WP admin > Appearance > any non-acitve block theme > Live preview.
  • The editor opens to preview the theme.
  • Click the editor canvas to switch to edit mode.
  • Click the button 'Activate {theme name}' at the top right of the screen.
  • Inspect the DOM and select the element with role=dialog and class entities-saved-states__panel.
  • In the dev tools inspector accessibility tab observe that the text passed as additionalPrompt is used in the labeling of the element.

Image

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Editor/packages/editor[Status] In ProgressTracking issues with work in progress[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