patternfly / patternfly/patternfly-react

Bug - MenuToggle - aria labelling doesn't work as intended

Open
#11,805 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A11y PF Team Stale
Dominant language
TypeScript
Stars
862
Forks
392
Avg merge
4d 8h
Merged PRs (30d)
9

Description

Describe the problem
Per https://github.com/patternfly/patternfly/issues/6562, we need to update how aria labeling is handled in MenuToggle, namely:

  • Right now the aria-label on the MenuToggle does nothing since the text content is taking precedence,

  • We need to ensure MenuToggle's with dynamic text content have an accessible name that includes a static label as well as the dynamic toggle content

How do you reproduce the problem?
Go to a MenuToggle and Select example and navigate both with VoiceOver. Notice that only the text content gets announced. Then choose a new option in the Select example, and notice that there's no context for what the Select is actually for but rather just the current text content.

Expected behavior
Note this is most likely only for a non-typeahead and non-plain MenuToggle, basically only a MenuToggle whose content would be dynamic like in Select examples (where by default the toggle content may be "Choose an option", then choosing an option updates the toggle content to e.g. "Option 1").

  • MenuToggle should have an aria-labelledby on its internal button element that should reference the pf-v6-c-menu-toggle__button (if aria-label is passed; if aria-labelledby is passed to MenuToggle then this internal aria-labelledby should reference that ID instead) and pf-v6-c-menu-toggle__text elements -- this should only occur when aria-label or aria-labelledby are passed to MenuToggle

  • We should add aria-labelledby to the props interface to explicitly expose it

  • Examples using MenuToggle must be updated so that there is a unique/descriptive static label as well as its content label

Using the single select example in React, here's what the markup should end up looking similar to:

image

Is this issue blocking you?
List the workaround if there is one.

Screenshots
If applicable, add screenshots to help explain the issue.

What is your environment?

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

What is your product and what release date are you targeting?

Any other information?


Jira Issue: PF-1729

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the MenuToggle implementation, its props interface, and the React Select examples linked in the issue. Check how aria-label, aria-labelledby, and dynamic toggle text are currently rendered, then update the component and examples so the internal button has the required accessible name. Verify the resulting markup with the single-select example and VoiceOver.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
accessibility, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.