Skip to content

feat(MenuToggle): add aria-haspopup prop#12549

Open
Axel-DaMage wants to merge 1 commit into
patternfly:mainfrom
Axel-DaMage:feat/menu-toggle-aria
Open

feat(MenuToggle): add aria-haspopup prop#12549
Axel-DaMage wants to merge 1 commit into
patternfly:mainfrom
Axel-DaMage:feat/menu-toggle-aria

Conversation

@Axel-DaMage

@Axel-DaMage Axel-DaMage commented Jul 9, 2026

Copy link
Copy Markdown

Fixes #11792
Jira Issue: PF-1704

Description

As a followup to patternfly/patternfly#6561, this PR introduces the aria-haspopup prop to the MenuToggle component to improve screen reader accessibility.

Changes included:

  • Added the aria-haspopup prop to MenuToggleProps with a default value of "menu".
  • Passed the aria-haspopup attribute to the underlying <button> elements in MenuToggleBase.
  • Updated all Select component examples and demos to explicitly pass aria-haspopup="listbox", as Select inherently behaves as a listbox rather than a standard navigation menu.
  • Updated examples in Toolbar, Form, LoginPage, and Tooltip that utilize Select as a filter/dropdown to also explicitly pass aria-haspopup="listbox".
  • Maintained the default "menu" behavior for components that naturally function as menus (e.g., Dropdown, ActionList, DataList kebab actions, etc.).
  • Updated MenuToggle unit test snapshots to reflect the new default attribute.

Visuals

N/A - This is purely an accessibility (A11y) structural change, no visual regressions or changes are introduced.

Summary by CodeRabbit

  • New Features

    • Improved accessibility support for dropdown-style controls by clearly indicating listbox popups.
    • Expanded toggle support so more selection controls can expose the correct popup type.
  • Bug Fixes

    • Updated multiple select, toolbar, login, and tooltip examples to announce dropdown behavior more accurately to assistive technologies.
    • Fixed missing accessibility metadata on several toggle buttons for a more consistent user experience.

Adds the aria-haspopup prop to MenuToggle with a default value of 'menu'. Updates all Select implementations across examples and demos to explicitly pass aria-haspopup="listbox" to properly reflect their semantic role, addressing issue patternfly#11792 (PF-1704).
Copilot AI review requested due to automatic review settings July 9, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds an optional aria-haspopup prop to MenuToggleProps (default "menu"), applies it across MenuToggle's typeahead, split-button, and default render branches, and updates numerous Select, Toolbar, Tooltip, LoginPage, and Form example files to pass aria-haspopup="listbox".

Changes

aria-haspopup support

Layer / File(s) Summary
MenuToggle prop and render logic
packages/react-core/src/components/MenuToggle/MenuToggle.tsx
Adds optional 'aria-haspopup' to MenuToggleProps (default 'menu'), destructures it in render, and applies it to typeahead, split-button, and default <button> variants.
Select example toggles
packages/react-core/src/components/Select/examples/* (SelectBasic, SelectCheckbox, SelectFooter, SelectGrouped, SelectMultiTypeahead, SelectMultiTypeaheadCheckbox, SelectMultiTypeaheadCreatable, SelectOptionVariations, SelectTypeahead, SelectTypeaheadCreatable, SelectValidated, SelectViewMore)
Each MenuToggle toggle renderer now includes aria-haspopup="listbox".
Toolbar example toggles
packages/react-core/src/components/Toolbar/examples/* (ToolbarComponentManagedToggleGroups, ToolbarConsumerManagedToggleGroups, ToolbarCustomLabelGroupContent, ToolbarGroups, ToolbarStacked, ToolbarWithFilters)
MenuToggle elements for Status, Risk, Resource, and other filter selects now include aria-haspopup="listbox".
Other component examples
packages/react-core/src/components/Tooltip/examples/TooltipOptions.tsx, packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx, packages/react-core/src/components/Form/examples/FormState.tsx
MenuToggle elements in tooltip position/flip selectors, the language selector, and the form's select example now include aria-haspopup="listbox".

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Suggested reviewers: mcoker, nicolethoen, kmcfaul

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an aria-haspopup prop to MenuToggle.
Linked Issues check ✅ Passed The PR adds the new MenuToggle aria-haspopup prop with default menu and updates Select and other examples to use listbox where appropriate.
Out of Scope Changes check ✅ Passed The changes stay focused on MenuToggle accessibility and related example updates, with no unrelated code paths introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/react-core/src/components/MenuToggle/MenuToggle.tsx (1)

76-77: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Improve the JSDoc comment for the aria-haspopup prop.

The comment "Default value of aria-haspopup" doesn't describe what the prop does. A more descriptive comment would help consumers understand its purpose and valid values.

📝 Suggested comment improvement
-  /** Default value of aria-haspopup */
-  'aria-haspopup'?: 'menu' | 'listbox' | 'dialog' | boolean;
+  /** Indicates the type of popup controlled by this toggle. Defaults to 'menu'. */
+  'aria-haspopup'?: 'menu' | 'listbox' | 'dialog' | boolean;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/react-core/src/components/MenuToggle/MenuToggle.tsx` around lines 76
- 77, The JSDoc for the aria-haspopup prop in MenuToggleProps is too generic and
should describe the prop’s purpose and accepted values instead of only stating a
default. Update the comment near the aria-haspopup declaration in MenuToggle.tsx
to explain that it indicates what kind of popup the toggle controls, and mention
the allowed values used by the MenuToggle component. Keep the wording concise
and aligned with the prop’s accessibility intent.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/react-core/src/components/MenuToggle/MenuToggle.tsx`:
- Around line 76-77: The JSDoc for the aria-haspopup prop in MenuToggleProps is
too generic and should describe the prop’s purpose and accepted values instead
of only stating a default. Update the comment near the aria-haspopup declaration
in MenuToggle.tsx to explain that it indicates what kind of popup the toggle
controls, and mention the allowed values used by the MenuToggle component. Keep
the wording concise and aligned with the prop’s accessibility intent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ee5ada4-c051-46db-8e2e-10e12fdfc4ed

📥 Commits

Reviewing files that changed from the base of the PR and between f8bcd7c and 122aebb.

⛔ Files ignored due to path filters (1)
  • packages/react-core/src/components/MenuToggle/__tests__/__snapshots__/MenuToggle.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (22)
  • packages/react-core/src/components/Form/examples/FormState.tsx
  • packages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsx
  • packages/react-core/src/components/MenuToggle/MenuToggle.tsx
  • packages/react-core/src/components/Select/examples/SelectBasic.tsx
  • packages/react-core/src/components/Select/examples/SelectCheckbox.tsx
  • packages/react-core/src/components/Select/examples/SelectFooter.tsx
  • packages/react-core/src/components/Select/examples/SelectGrouped.tsx
  • packages/react-core/src/components/Select/examples/SelectMultiTypeahead.tsx
  • packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCheckbox.tsx
  • packages/react-core/src/components/Select/examples/SelectMultiTypeaheadCreatable.tsx
  • packages/react-core/src/components/Select/examples/SelectOptionVariations.tsx
  • packages/react-core/src/components/Select/examples/SelectTypeahead.tsx
  • packages/react-core/src/components/Select/examples/SelectTypeaheadCreatable.tsx
  • packages/react-core/src/components/Select/examples/SelectValidated.tsx
  • packages/react-core/src/components/Select/examples/SelectViewMore.tsx
  • packages/react-core/src/components/Toolbar/examples/ToolbarComponentManagedToggleGroups.tsx
  • packages/react-core/src/components/Toolbar/examples/ToolbarConsumerManagedToggleGroups.tsx
  • packages/react-core/src/components/Toolbar/examples/ToolbarCustomLabelGroupContent.tsx
  • packages/react-core/src/components/Toolbar/examples/ToolbarGroups.tsx
  • packages/react-core/src/components/Toolbar/examples/ToolbarStacked.tsx
  • packages/react-core/src/components/Toolbar/examples/ToolbarWithFilters.tsx
  • packages/react-core/src/components/Tooltip/examples/TooltipOptions.tsx

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MenuToggle - add aria-haspopup prop

2 participants