Skip to content

Tools panel: Synced the visible label and accessible name - #68592

Closed
im3dabasia wants to merge 6 commits into
WordPress:trunkfrom
im3dabasia:fix/accessibility-dropdown-menu
Closed

im3dabasia wants to merge 6 commits into
WordPress:trunkfrom
im3dabasia:fix/accessibility-dropdown-menu

Conversation

@im3dabasia

Copy link
Copy Markdown
Contributor

Fixes: #65241

What?

Updated aria-labels for Tools Panel items to match their visible text.

Why?

Resolved mismatches between visual labels and accessible names, improving accessibility.

How?

Refactored aria-label generation to reflect visible text directly without adding unnecessary text.

Testing Instructions

  1. Open the Site Editor > Styles > Colors > Elements options (the ellipsis icon button).
  2. Open the Elements options popover.
  3. Observe the toggle-able items in the menu have a visible text like H1, H2, etc.
  4. Verify that the aria-label matches the visible text for toggle-able items.

Screenshots or screencast

Before After
Screenshot 2025-01-10 at 3 36 40 PM Screenshot 2025-01-10 at 3 32 24 PM

@im3dabasia
im3dabasia requested a review from ajitbohra as a code owner January 10, 2025 10:07
@github-actions

github-actions Bot commented Jan 10, 2025 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: afercia <afercia@git.wordpress.org>
Co-authored-by: carolinan <poena@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@im3dabasia

Copy link
Copy Markdown
Contributor Author

As mentioned in the issue, there is another accessibility concern: the aria-label is set as "Elements options" while the title of the popover is "Elements"

The required change needs to be made in this file. However, removing the word "options" raises an ESLint error (@wordpress/i18n-no-placeholders-only), which prohibits the use of translation functions with placeholders only.

image
Code Reference

const dropDownMenuLabelText = sprintf(
// translators: %s: The name of the tool e.g. "Color" or "Typography".
_x( '%s options', 'Button label to reveal tool panel options' ),
labelText
);

I would love to hear your thoughts on how to approach this part of the issue

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components labels Jan 11, 2025
@im3dabasia

Copy link
Copy Markdown
Contributor Author

Hi @afercia ,

When you have a moment, Please review my PR .

Looking forward for the feedback.

@afercia

afercia commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

When you have a moment, Please review my PR .

@im3dabasia thanks for raising this PR.
There's a few e2e tests and unit tests failing. As far as I can tell they all fail because of the accessible name change necause they use selectors to target the previous names such as:
'Show link'
'Show content'
'Drop cap' / 'Show drop cap'
'Appearance' / 'Show Appearance'
etc.

Once fixed, I guss the snapshots of the failing unit test should be regenerated. You can do that by passing the related flag when running the test, for example:

npm run test:unit -- --updateSnapshot --testPathPattern {test file path here starring with packages/}

From a design perspective, the Tools Panel is still unclear to me.
As an user, when the popover opens, I'm not sure I understand what I can do here. There's nothing, absolutely nothing, that visually tells me this settings are meant to toggle the visibility of the related settings in the main panel. The popover visibel title only says 'Elements' (and siilarly for other kind of settings). Instead, it should really explain the list of items below is to toggle the visibility of those settings.
Cc @WordPress/gutenberg-design

Screenshot 2025-03-11 at 08 30 17

@im3dabasia

Copy link
Copy Markdown
Contributor Author

Thank you @afercia for your thoughtful feedback! I really appreciate you explaining the snapshot update process - I've learned something valuable today.

I agree with your design feedback about the Tools Panel's lack of clarity. For this PR though, I'm specifically focusing on addressing the accessibility issue where visible and accessible names don't match. I'll fix all the test failures caused by these name changes and regenerate the snapshots as you suggested.

The broader UX improvements can be addressed in a separate PR after reaching consensus with the design team.

@im3dabasia
im3dabasia force-pushed the fix/accessibility-dropdown-menu branch from 4f5c2d8 to 93d7c92 Compare March 11, 2025 10:23
@im3dabasia

Copy link
Copy Markdown
Contributor Author

Hey @afercia

I have fixed the failing test cases. When you get a chance please review my PR

@carolinan

Copy link
Copy Markdown
Contributor

Why do these need an aria-label when there is a visible text in the button?

@t-hamano

Copy link
Copy Markdown
Contributor

Why do these need an aria-label when there is a visible text in the button?

I think you're right - we don't need an aria-label that is exactly the same as the displayed text.

However, we may need to do something about the resettable buttons, because the text "Reset" has the aria-hidden attribute applied to it, which means that screen readers won't read it.

reset-button

@ramonjd ramonjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

From a tools panel perspective, this looks good to me.

The items already carry role="menuitemcheckbox" and aria-checked from isSelected, so the shown/hidden state is exposed through the role.

The visible text and the accessible name are now identical.

Probably just needs a rebase.

### Bug Fixes

- `Button`: Remove fixed width from small and compact buttons with icons ([#69378](https://github.com/WordPress/gutenberg/pull/69378)).
- `ToolsPanel`: Updated the ARIA labels to match the visible text to improve accessibilty ([#68592](https://github.com/WordPress/gutenberg/pull/68592)).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- `ToolsPanel`: Updated the ARIA labels to match the visible text to improve accessibilty ([#68592](https://github.com/WordPress/gutenberg/pull/68592)).
- `ToolsPanel`: Updated the ARIA labels to match the visible text to improve accessibility ([#68592](https://github.com/WordPress/gutenberg/pull/68592)).

@aaronrobertshaw

Copy link
Copy Markdown
Contributor

Thanks for this one @im3dabasia 👍

From what I can see #84341 has already fixed the mismatch this PR targets.

#84341 puts the visible name first, for example "Line height, show" and "Line height, hide and reset". Default items read "Size, reset to default".

The name now starts with the visible text, so voice control users can say what they see. This PR conflicts on those same lines.

I'll close this one for now. If there's something further you think needs addressing, please feel free to re-open or submit a follow-up issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tools panel: avoid unnecessary mismatch between visible label and accessible name

6 participants