feat(MenuToggle): add aria-haspopup prop#12549
Conversation
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).
WalkthroughAdds an optional Changesaria-haspopup support
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/react-core/src/components/MenuToggle/MenuToggle.tsx (1)
76-77: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueImprove the JSDoc comment for the
aria-haspopupprop.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
⛔ Files ignored due to path filters (1)
packages/react-core/src/components/MenuToggle/__tests__/__snapshots__/MenuToggle.test.tsx.snapis excluded by!**/*.snap
📒 Files selected for processing (22)
packages/react-core/src/components/Form/examples/FormState.tsxpackages/react-core/src/components/LoginPage/examples/LoginPageLanguageSelect.tsxpackages/react-core/src/components/MenuToggle/MenuToggle.tsxpackages/react-core/src/components/Select/examples/SelectBasic.tsxpackages/react-core/src/components/Select/examples/SelectCheckbox.tsxpackages/react-core/src/components/Select/examples/SelectFooter.tsxpackages/react-core/src/components/Select/examples/SelectGrouped.tsxpackages/react-core/src/components/Select/examples/SelectMultiTypeahead.tsxpackages/react-core/src/components/Select/examples/SelectMultiTypeaheadCheckbox.tsxpackages/react-core/src/components/Select/examples/SelectMultiTypeaheadCreatable.tsxpackages/react-core/src/components/Select/examples/SelectOptionVariations.tsxpackages/react-core/src/components/Select/examples/SelectTypeahead.tsxpackages/react-core/src/components/Select/examples/SelectTypeaheadCreatable.tsxpackages/react-core/src/components/Select/examples/SelectValidated.tsxpackages/react-core/src/components/Select/examples/SelectViewMore.tsxpackages/react-core/src/components/Toolbar/examples/ToolbarComponentManagedToggleGroups.tsxpackages/react-core/src/components/Toolbar/examples/ToolbarConsumerManagedToggleGroups.tsxpackages/react-core/src/components/Toolbar/examples/ToolbarCustomLabelGroupContent.tsxpackages/react-core/src/components/Toolbar/examples/ToolbarGroups.tsxpackages/react-core/src/components/Toolbar/examples/ToolbarStacked.tsxpackages/react-core/src/components/Toolbar/examples/ToolbarWithFilters.tsxpackages/react-core/src/components/Tooltip/examples/TooltipOptions.tsx
Fixes #11792
Jira Issue: PF-1704
Description
As a followup to patternfly/patternfly#6561, this PR introduces the
aria-haspopupprop to theMenuTogglecomponent to improve screen reader accessibility.Changes included:
aria-haspopupprop toMenuTogglePropswith a default value of"menu".aria-haspopupattribute to the underlying<button>elements inMenuToggleBase.Selectcomponent examples and demos to explicitly passaria-haspopup="listbox", asSelectinherently behaves as a listbox rather than a standard navigation menu.Toolbar,Form,LoginPage, andTooltipthat utilizeSelectas a filter/dropdown to also explicitly passaria-haspopup="listbox"."menu"behavior for components that naturally function as menus (e.g.,Dropdown,ActionList,DataListkebab actions, etc.).MenuToggleunit 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
Bug Fixes